object.reduce
Reduces an object to a value that is the accumulated result of running each property in the object through a callback.
Last updated 8 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install object.reduce 
SYNC missed versions from official npm registry.

object.reduce NPM version NPM monthly downloads Linux Build Status

Reduces an object to a value that is the accumulated result of running each property in the object through a callback.

Install

Install with npm:

$ npm install --save object.reduce

Install with yarn:

$ yarn add object.reduce

Install with bower

$ bower install object.reduce --save

Usage

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.)_

Params

  • object {Object}: The object to iterate over (the iteratee)
  • fn {Function}: The function invoked per iteration.
  • init {Object}: The initial value to use for the accumulator.
  • thisArg {Object}: (optional) Object to use as the invocation context for the iterator (expose as this inside the iterator)

Executes the given callback fn once for each own enumerable property in the object. The callback receives the following 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('object.reduce');
var a = {a: 'foo', b: 'bar', c: 'baz'};

reduce(a, function(acc, value, key, obj) {
  acc[key] = value.toUpperCase();
  return acc;
}, {});

//=> {a: 'FOO', b: 'BAR', c: 'BAZ'};

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.5.0, on April 17, 2017.

Current Tags

  • 1.0.1                                ...           latest (8 years ago)

7 Versions

  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.1.7                                ...           10 years ago
  • 0.1.6                                ...           10 years ago
  • 0.1.5                                ...           10 years ago
  • 0.1.4                                ...           10 years ago
  • 0.1.3                                ...           10 years ago
Downloads
Total 4
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE