New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

put-value

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

put-value

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

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

put-value npmjs.com The MIT License

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

code climate standard code style travis build status coverage status dependency status

Features

  • updates value of key only if key exists
  • updates only existing values of obj when object is given to key
  • because set-value update values if exist and add if not exist
  • returns original object if key is not an object or string
  • returns empty object if obj is not an object
  • returns modified object otherwise

Install

npm i put-value --save
npm test

Usage

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'
//   }
// }

Contributing

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.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github

Keywords

dot

FAQs

Package last updated on 09 Jul 2015

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