Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0
reduce-obj
Reduce over an object's key-value pairs
Installation
$ npm install @f/reduce-obj
Usage
var reduce = require('@f/reduce-obj')
var fruits = {apples: 2, oranges: 3}
var numFruits = reduce(sum, 0, fruits)
function sum (a, b) {
return a + b
}
API
reduce(cb, initialValue, obj)
cb- Callback called for each key/value pair inobjwith an accumlator value and the current item.
function cb (acc, val, key, obj) {}
initialValue- First value for the accumulatorobjObject to be reduced
Returns: The accumulated value
License
MIT