Array to segregate
Partion function that puts the item in the right or left bucket depenbding on if it returns a falsish values
Optional
predicate: ((item, index) => any)Predicate to filter the array
A tuple with two arrays the first array holding the values for which the predicate returned true and the second array holding the values for which the predicate returned false.
// Segregate even and odd numbers
const [ even, odd ] = partition([ 1, 2, 3, 4, 5 ], i => i % 2 == 0);
console.log(even); // [ 2, 4 ]
console.log(odd); // [ 1, 3, 5 ]
Segregate the elements of the source array into two distinct arrays the first array holding the values for which the predicate returned true and the second array holding the values for which the predicate returned false.