Options
All
  • Public
  • Public/Protected
  • All
Menu

Module iterable/reduce

Index

References

Type aliases

Functions

References

Renames and re-exports reduce

Type aliases

IterableReduceFunc<T, R>: (previousValue: R, currentValue: T) => R

Type parameters

  • T

  • R

Type declaration

    • (previousValue: R, currentValue: T): R
    • Parameters

      • previousValue: R
      • currentValue: T

      Returns R

Functions

  • Returns a single item by iterating through the iterable, successively calling the iterable function and passing it an previousValue value and the current value from the iterable, and then passing the result to the next call.

    example
     const numbers = [1, 2, 3];
    const plus = (a, b) => a + b;

    reduce(plus, 10, numbers); //=> 16

    Type parameters

    • T

    • R

    Parameters

    • reducer: IterableReduceFunc<T, R>

      The iterable function. Receives two values, the previous element and the current element from the iterable.

    • initialValue: R

      The initial value.

    • iterable: Iterable<T>

      The iterable target to iterate over.

    Returns R

    The final, accumulated value.

  • Returns a single item by iterating through the iterable, successively calling the iterable function and passing it an previousValue value and the current value from the iterable, and then passing the result to the next call.

    example
     const numbers = [1, 2, 3];
    const plus = (a, b) => a + b;

    reduce(plus, 10, numbers); //=> 16

    Type parameters

    • T

    • R

    Parameters

    • reducer: IterableReduceFunc<T, R>

      The iterable function. Receives two values, the previous element and the current element from the iterable.

    • initialValue: R

      The initial value.

    Returns (iterable: Iterable<T>) => R

    The final, accumulated value.

      • (iterable: Iterable<T>): R
      • Parameters

        • iterable: Iterable<T>

        Returns R

  • Returns a single item by iterating through the iterable, successively calling the iterable function and passing it an previousValue value and the current value from the iterable, and then passing the result to the next call.

    example
     const numbers = [1, 2, 3];
    const plus = (a, b) => a + b;

    reduce(plus, 10, numbers); //=> 16

    Type parameters

    • T

    • R

    Parameters

    • reducer: IterableReduceFunc<T, R>

      The iterable function. Receives two values, the previous element and the current element from the iterable.

    Returns CurriedFunction2<R, Iterable<T>, R>

    The final, accumulated value.

Generated using TypeDoc