Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/core/main/exports.ts>AsyncReducer.minBy

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
variable AsyncReducer.minBy
import { AsyncReducer } from "https://deno.land/x/rimbu@1.0.3/core/main/exports.ts";
const { minBy } = AsyncReducer;

Returns a Reducer that remembers the minimum value of the inputs using the given compFun to compare input values

Examples

Example 1

const stream = Stream.of('abc', 'a', 'abcde', 'ab')
console.log(stream.minBy((s1, s2) => s1.length - s2.length))
// 'a'

type

{ <T>(compFun: (v1: T, v2: T) => MaybePromise<number>): AsyncReducer<T, T | undefined>; <T, O>(compFun: (v1: T, v2: T) => MaybePromise<number>, otherwise: AsyncOptLazy<O>): AsyncReducer<T, T | O>; }