JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 994730
  • Score
    100M100P100Q181579F
  • License MIT

Update object by mapping diff properties

Package Exports

  • update-diff

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (update-diff) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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