Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reduce-object

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reduce-object

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 valu

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
60K
increased by12.66%
Maintainers
1
Weekly downloads
 
Created
Source

reduce-object NPM version

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 i reduce-object --save

Run tests

npm test

Usage

Executes the callback function 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.
var reduce = require('reduce-object');

var a = {a: 'foo', b: 'bar', c: {}};

var obj = reduce(a, function (acc, value, key, orig) {
  if (typeof value === 'object') {
    acc[key] = {what: 'huh?'};
  } else {
    acc[key] = value.toUpperCase(); // why?
  }
  return acc;
}, {});

console.log(obj);
//=> {a: 'FOO', b: 'BAR', c: {what: 'huh?'}};

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors. Released under the MIT license


This file was generated by verb-cli on September 20, 2014.

Keywords

FAQs

Package last updated on 28 Sep 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc