Skip to main content

type maxBy

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

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

Definition

maxBy: {
    <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>;
  }