A tuple containing the two arrays.
const [even, odd] = partition(
[1, 2, 3, 4, 5],
(n) => n % 2 === 0 // (true if n is even)
)
console.log(even) // [2, 4]
console.log(odd) // [1, 3, 5]
import { isString } from 'uft'
const [strings, other] = partition(
[1, 'foo', { bar: '' }],
isString
)
strings // type: string[]
other // type: (number | { bar: string })[]
Generated using TypeDoc
Creates two arrays, the first containing the elements for which the predicate returned true, and the second containing the elements for which the predicate returned false.