0.2.1 • Published 10 years ago
@f/reduce-array v0.2.1
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-arrayUsage
var reduce = require('@f/reduce-array')
var sum = reduce(
function (prev, curr) {
return prev + curr
},
2,
[2, 3, 6]
)
// sum -> 13API
reduceArray(cb, initialValue, arr)
cb- Callback called for eacharritem with a accumlator value and the current item. Optional index and array
function cb (accumulator, currentItem, index, array) {}initialValue- First value for the accumulatorarrArray to be reduced
Returns: The accumulated value
License
MIT