An object to keep track of an item considered to be a minimum, based on the given getValue selector.

Items with a non-finite numeric value (e.g. NEGATIVE_INFINITY,POSITIVE_INFINITY, NaN, null, undefined) are ignored.

See

Example

export function minBy<T>(
iterable: Iterable<T>,
selector: (item: T) => number
): [item: T, value: number] | [] {
const min = new MinimumTracker<T>(selector);
for (const item of iterable) {
min.consider(item);
}
return min.result;
}

Type Parameters

  • T

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

Properties

_result?: [item: T, value: number]
getValue: ((item: T) => undefined | null | number)

Type declaration

    • (item: T): undefined | null | number
    • Parameters

      • item: T

      Returns undefined | null | number

predicate: ((current: number, candidate: number) => boolean)

Type declaration

    • (current: number, candidate: number): boolean
    • Parameters

      • current: number
      • candidate: number

      Returns boolean

Accessors

Methods

Generated using TypeDoc