Options
All
  • Public
  • Public/Protected
  • All
Menu

Module array/reduce

Index

References

Type aliases

Functions

References

Renames and re-exports reduce

Type aliases

ReduceFunc<T, R>: (acc: R, elem: T, index: number, arr: ArrayLike<T>) => R

Type parameters

  • T

  • R

Type declaration

    • (acc: R, elem: T, index: number, arr: ArrayLike<T>): R
    • Parameters

      • acc: R
      • elem: T
      • index: number
      • arr: ArrayLike<T>

      Returns R

Functions

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

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

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

    Type parameters

    • T

    • R

    Parameters

    • fn: ReduceFunc<T, R>

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

    • acc: R

      The accumulator value.

    • list: ArrayLike<T>

    Returns R

    The final, accumulated value.

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

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

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

    Type parameters

    • T

    • R

    Parameters

    • fn: ReduceFunc<T, R>

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

    • acc: R

      The accumulator value.

    Returns (list: ArrayLike<T>) => R

    The final, accumulated value.

      • (list: ArrayLike<T>): R
      • Parameters

        • list: ArrayLike<T>

        Returns R

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

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

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

    Type parameters

    • T

    • R

    Parameters

    • fn: ReduceFunc<T, R>

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

    Returns CurriedFunction2<R, ArrayLike<T>, R>

    The final, accumulated value.

Generated using TypeDoc