Skip to content

Commit

Permalink
chore(stackflow/core): Type inference friendly divideBy (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
ENvironmentSet authored Jan 20, 2025
1 parent 18609d1 commit 5fc54cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-colts-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@stackflow/core": patch
---

Made `divideBy` to be friendly to type inference.
2 changes: 1 addition & 1 deletion core/src/makeCoreStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function makeCoreStore(options: MakeCoreStoreOptions): CoreStore {
initialEvents,
initialContext: options.initialContext ?? {},
}) ?? initialEvents,
initialPushedEventsByOption as (PushedEvent | StepPushedEvent)[],
initialPushedEventsByOption,
);

const isInitialActivityIgnored =
Expand Down
8 changes: 4 additions & 4 deletions core/src/utils/divideBy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const divideBy = <T>(
export const divideBy = <T, U extends T>(
arr: T[],
predicate: (t: T) => boolean,
): [T[], T[]] => {
const satisfied: T[] = [];
predicate: (t: T) => t is U,
): [U[], T[]] => {
const satisfied: U[] = [];
const unsatisfied: T[] = [];

arr.forEach((element) => {
Expand Down

0 comments on commit 5fc54cb

Please sign in to comment.