Skip to main content

type minBy

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

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

Definition

minBy: {
    <T>(compFun: (v1: T, v2: T) => number): Reducer<T, T | undefined>;
    <T, O>(compFun: (v1: T, v2: T) => number, otherwise: OptLazy<O>): Reducer<T, T | O>;
  }