Skip to content

Commit

Permalink
feat(partitionuntil): add partitionUntil function
Browse files Browse the repository at this point in the history
  • Loading branch information
djcsdy committed Jan 15, 2022
1 parent 610d3ec commit b118fde
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,19 @@ export function partitionWhileFn<T>(
return array => partitionWhile(array, predicate);
}

export function partitionUntil<T>(
array: ArrayLike<T>,
predicate: (element: T) => boolean
): [T[], T[]] {
return partitionWhile(array, element => !predicate(element));
}

export function partitionUntilFn<T>(
predicate: (element: T) => boolean
): (array: ArrayLike<T>) => [T[], T[]] {
return array => partitionUntil(array, predicate);
}

/** Takes two arrays and returns an array of corresponding pairs.
*
* If one of the supplied arrays is shorter than the other, then the excess
Expand Down

0 comments on commit b118fde

Please sign in to comment.