Splits an iterable structure into two — [matching, rest] — by a predicate.
[matching, rest]
Both halves preserve the input container type. With an async predicate the result is wrapped in a Promise.
Promise
partition([1, 2, 3, 4], v => v % 2 === 0)// [[2, 4], [1, 3]]partition({ a: 1, b: 2 }, ([, v]) => v > 1)// [{ b: 2 }, { a: 1 }] Copy
partition([1, 2, 3, 4], v => v % 2 === 0)// [[2, 4], [1, 3]]partition({ a: 1, b: 2 }, ([, v]) => v > 1)// [{ b: 2 }, { a: 1 }]
Splits an iterable structure into two —
[matching, rest]— by a predicate.Both halves preserve the input container type. With an async predicate the result is wrapped in a
Promise.