Skip to main content
variable partition
import { partition } from "https://deno.land/x/30_seconds_of_typescript@v1.0.1/util.ts";

Groups the elements into two arrays, depending on the provided function's truthiness for each element.

Use Array.prototype.reduce() to create an array of two arrays. Use Array.prototype.push() to add elements for which fn returns true to the first array and elements for which fn returns false to the second one.

type

(arr: any[], fn: Predicate) => unknown