A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/tunnckocore/put-value below:

tunnckoCore/put-value: Update only existing values from an object, works with dot notation paths like `a.b.c` and support deep nesting.

Update only existing values from an object, works with dot notation paths like a.b.c and support deep nesting.

npm i put-value --save
npm test

For more use-cases see the tests

var put = require('put-value')
var obj = {
  a: {
    foo: 'bar'
  },
  b: {
    bb: 'bbb'
  }
}

put(123) //=> empty object {}
put(obj, {a: {bar: 'baz'}}) //=> original `obj`
put(obj, {a: 'foo'}})
//=> {
//   a: 'foo',
//   b: {
//     bb: 'bbb'
//   }
// }

put(obj, {zzz: 'xxx'}) //=> original `obj`
put(obj, 'foo', 'baz') //=> original `obj`
put(obj, 'foo.bar', 'baz') //=> original `obj`
put(obj, 'a', {foo: 123})
//=> {
//   a: {
//     foo: 123
//   },
//   b: {
//     bb: 'bbb'
//   }
// }

put(obj, 'a.foo', {baz: 'aaa'})
//=> {
//   a: {
//     foo: {
//       baz: 'aaa'
//     }
//   },
//   b: {
//     bb: 'bbb'
//   }
// }

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4