Function partition
- partition<T>(array, predicate): [T[], T[]]
Type Parameters
Parameters
Returns [T[], T[]]
A tuple of two arrays. The first array contains all elements that match the predicate, the second contains all elements that do not.
- partition<T, U>(array, predicate): [U[], Exclude<T, U>[]]
Returns a tuple of two arrays with the first one containing all elements in the given array that match the given predicate and the second one containing all that do not.
This version of the function is a type-guard version of the function. It allows you to specify a type-guard predicate function that narrows the type of the elements in the array.
Type Parameters
Parameters
Returns [U[], Exclude<T, U>[]]
A tuple of two arrays. The first array contains all elements that match the predicate, the second contains all elements that do not.
Returns a tuple of two arrays with the first one containing all elements in the given array that match the given predicate and the second one containing all that do not.