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

Splits values into two groups according to a predicate function, which specifies which group an element in the input collection belongs to. If the predicate function returns a truthy value, the collection element belongs to the first group; otherwise, it belongs to the second group.

Use Array.prototype.reduce() and Array.prototype.push() to add elements to groups, based on the value returned by fn for each element.

type

<T = any>(arr: T[], filter: Predicate) => unknown