object.reduce
Reduces an object to a value that is the accumulated result of running each property in the object through a callback.
Executes the callback function once for each own enumerable property in the object, receiving four arguments: the initial value (or value from the previous callback call), the value
of the current property, the key
of the current property, and the object
over which the function is iterating. Node.js/JavaScript utility.
Install
Install with npm
npm i object.reduce --save
Install with bower
bower install object.reduce --save
Run tests
npm test
Usage
A callback function is executed once for each own enumerable property in the object, receiving four arguments:
acc
: the initial value (or value from the previous callback call),value
: the of the current property,key
: the of the current property, and- the original
object
over which the function is iterating.
Example
var reduce = require('reduce-object');
var a = {a: 'foo', b: 'bar', c: 'baz'};
reduce(a, function (acc, value, key, obj) {
acc[key] = value.toUpperCase();
return acc;
}, {});
Author
Jon Schlinkert
License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb-cli on March 24, 2015.