Licence
MIT
Version
1.0.0
Deps
4
Vulns
0
Weekly
0
reduce
Reduce over the elements of a container
Installation
$ npm install @f/reduce
Usage
var reduce = require('@f/reduce')
var fruits = {apples: 2, oranges: 3}
var numFruits = reduce(sum, 0, fruits)
function sum (a, b) {
return a + b
}
API
reduce(cb, initialValue, collection)
cb- Callback called for eachcollectionitem with a accumlator value and the current item.
function cb (accumulator, currentItem, key, colllection) {}
initialValue- First value for the accumulatorarrCollection to be reduced
Returns: The accumulated value
License
MIT