Function reduce

  • Returns the reduced value defined by given reducer function, which is repeatedly invoked for each value in iterable, being passed the current reduced value and the next value. Equivalent to array.reduce.

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T>
    • reducer: ((previousValue, currentValue, currentIndex, iterable) => T)
        • (previousValue, currentValue, currentIndex, iterable): T
        • Parameters

          • previousValue: T
          • currentValue: T
          • currentIndex: number
          • iterable: Iterable<T>

          Returns T

    • Optional initialValue: T

    Returns T

  • Returns the reduced value defined by given reducer function, which is repeatedly invoked for each value in iterable, being passed the current reduced value and the next value. Equivalent to array.reduce.

    Type Parameters

    • T

    • U

    Parameters

    • iterable: Iterable<T>
    • reducer: ((previousValue, currentValue, currentIndex, iterable) => U)
        • (previousValue, currentValue, currentIndex, iterable): U
        • Parameters

          • previousValue: U
          • currentValue: T
          • currentIndex: number
          • iterable: Iterable<T>

          Returns U

    • initialValue: U

    Returns U