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

Returns the minimum/maximum value of an array, after applying the provided function to set comparing rule.

Use Array.prototype.reduce() in combination with the comparator function to get the appropriate element in the array. You can omit the second parameter, comparator, to use the default one that returns the minimum element in the array.

type

<T extends number | string | AnyObject = number>(arr: T[], comparator?: Function) => unknown