Socket
Socket
Sign inDemoInstall

object.reduce

Package Overview
Dependencies
2
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    object.reduce

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


Version published
Maintainers
1
Install size
20.3 kB
Created

Readme

Source

object.reduce NPM version

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 with npm

npm i object.reduce --save

Install with bower

bower install object.reduce --save

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('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'};

Running tests

Install dev dependencies:

npm i -d && npm test

Contributing

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

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on April 25, 2015.

Keywords

FAQs

Last updated on 25 Apr 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc