Function reduce

  • Reduces an iterable to a single value by applying the provided reducer function against an accumulator and each element yielded by the iterable (in the order in which they are received).

    The first invocation of the reducer will receive the first value yielded by the underlying iterable as its accumulator and the second value yielded as its currentValue argument.

    Type Parameters

    Type Parameters

    • T

    Parameters

    • reducer: ((accumulator: T, currentValue: T) => T)
        • (accumulator: T, currentValue: T): T
        • Parameters

          • accumulator: T
          • currentValue: T

          Returns T

    • iterable: Iterable<T> | AsyncIterable<T>

    Returns Promise<T>

  • Reduces an iterable to a single value by applying the provided reducer function against an accumulator and each element yielded by the iterable (in the order in which they are received).

    Type Parameters

    Type Parameters

    • T

    • R

    Parameters

    • reducer: ((accumulator: R, currentValue: T) => R)
        • (accumulator: R, currentValue: T): R
        • Parameters

          • accumulator: R
          • currentValue: T

          Returns R

    • initialValue: R

      The value to use as the accumulator on the first invocation of the reducer function.

    • iterable: Iterable<T> | AsyncIterable<T>

    Returns Promise<R>

Generated using TypeDoc