import { partition } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/array/index.js";
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.
Examples
Example 1
Example 1
import { partition } from "@ayonli/jsext/array";
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
const [even, odd] = partition(arr, item => item % 2 === 0);
console.log(even); // [0, 2, 4, 6, 8]
console.log(odd); // [1, 3, 5, 7, 9]