Function reduce

Reduce for iterables

reduce([1, 2, 3], (acc, cur) => acc + cur, 0);
// Yields: 6

Iterable

Function

Start value

  • Type Parameters

    • V

    Parameters

    • it: AsyncIterable<V>
    • f: ((accumulator: V, current: V) => V)
        • (accumulator, current): V
        • Parameters

          • accumulator: V
          • current: V

          Returns V

    • start: V

    Returns Promise<V>

  • Type Parameters

    • V

    Parameters

    • it: Iterable<V> | V[]
    • f: ((accumulator: V, current: V) => V)
        • (accumulator, current): V
        • Parameters

          • accumulator: V
          • current: V

          Returns V

    • start: V

    Returns V