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

update-diff

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

update-diff

Update object by mapping diff properties

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
166K
decreased by-9.92%
Maintainers
1
Weekly downloads
 
Created
Source

update-diff unstable

Update object by mapping differences in order. Comes handy for organizing state updating.

npm install update-diff

let prop = require('update-diff')

let state = {propA: 0, propB: 1, propC: ['foo'], propD: 'bar'}

updateDiff(state, modifications, [
//initial mapping
{
	propA: value => value,
	propB: true,
	propC: Array.isArray
},
//second-pass mapping
{
	propX: (x, state) => state.propB + x
},
//third-pass mapping
{
	propA: (value, state) => state.propA ? 'a' : 'b'
}
])

// {propB: 1, propC: ['foo']}
  • obj-map-prop − map object properties by a dict
  • map-obj − map properties by single function
  • filter-obj − filter properties by single function

Credits

© 2017 Dima Yv. MIT License

Keywords

FAQs

Package last updated on 17 Oct 2017

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