Skip to content

Commit b118fde

Browse files
committed
feat(partitionuntil): add partitionUntil function
1 parent 610d3ec commit b118fde

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,19 @@ export function partitionWhileFn<T>(
861861
return array => partitionWhile(array, predicate);
862862
}
863863

864+
export function partitionUntil<T>(
865+
array: ArrayLike<T>,
866+
predicate: (element: T) => boolean
867+
): [T[], T[]] {
868+
return partitionWhile(array, element => !predicate(element));
869+
}
870+
871+
export function partitionUntilFn<T>(
872+
predicate: (element: T) => boolean
873+
): (array: ArrayLike<T>) => [T[], T[]] {
874+
return array => partitionUntil(array, predicate);
875+
}
876+
864877
/** Takes two arrays and returns an array of corresponding pairs.
865878
*
866879
* If one of the supplied arrays is shorter than the other, then the excess

0 commit comments

Comments
 (0)