Function: partition()
partition<
T
>(array
:T
[],predicate
: (value
:T
,index
:number
) =>boolean
):T
[][]
Partitions array
into a tuple of two arrays,
where one array contains all elements that satisfies predicate
,
and the other contains all elements that do not satisfy predicate
.
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
array | T [] | The array to partition. This array is not mutated. |
predicate | (value : T , index : number ) => boolean | The predicate function to determine in which partition the item should be placed. The function should return true for items that should be placed in the first partition, and false for those that should be placed in the second partition. |
Returns
T
[][]
A tuple of two arrays.