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

Applies fn to each value in arr, splitting it each time fn returns a new value.

Use Array.prototype.reduce() with an accumulator object that will hold the resulting array and the last value returned from fn. Use Array.prototype.push() to add each value in arr to the appropriate partition in the accumulator array.

type

<R = any>(arr: any[], fn: MapFunc<any, R>) => unknown