3.1.2 • Published 5 years ago

array-reduce-x v3.1.2

Weekly downloads
500
License
MIT
Repository
github
Last release
5 years ago

array-reduce-x

Reduce an array (from left to right) to a single value.

module.exports*

This method applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value.

Kind: Exported member
Returns: * - The value that results from the reduction.
Throws:

  • TypeError If array is null or undefined.
  • TypeError If callBack is not a function.
  • TypeError If called on an empty array without an initial value.
ParamTypeDescription
arrayarrayThe array to iterate over.
callBackfunctionFunction to execute for each element.
initialValue*Value to use as the first argument to the first call of the callback. If no initial value is supplied, the first element in the array will be used. Calling reduce on an empty array without an initial value is an error.

Example

import reduce from 'array-reduce-x';

console.log(
  reduce(
    [0, 1, 2, 3],
    function(a, b) {
      return a + b;
    },
    0,
  ),
); // sum is 6
3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.17

5 years ago

3.0.16

5 years ago

3.0.15

5 years ago

3.0.14

5 years ago

3.0.13

5 years ago

3.0.12

5 years ago

3.0.11

5 years ago

3.0.10

5 years ago

3.0.9

5 years ago

3.0.8

5 years ago

3.0.7

5 years ago

3.0.6

5 years ago

3.0.5

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.1.0

6 years ago

2.0.0

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago