reduce-array
Fast and functional array reduce implementation. Same concept as the native reduce implementation except different argument order for currying.
Installation
$ npm install @f/reduce-array
Usage
var reduce = require('@f/reduce-array')
var sum = reduce(
function (prev, curr) {
return prev + curr
},
2,
[2, 3, 6]
)
// sum -> 13
API
reduceArray(cb, initialValue, arr)
-
cb
- Callback called for eacharr
item with a accumlator value and the current item. Optional index and array
function cb (accumulator, currentItem, index, array) {}
-
initialValue
- First value for the accumulator -
arr
Array to be reduced
Returns: The accumulated value
License
MIT