upsert-value
Update or set nested values and any intermediaries with dot notation (`'a.b.c'`) paths.
Last updated 11 years ago by doowb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install upsert-value 
SYNC missed versions from official npm registry.

upsert-value NPM version Build Status

Update or set nested values and any intermediaries with dot notation ('a.b.c') paths.

Install with npm

$ npm i upsert-value --save

Usage

var upsert = require('upsert-value');

API

upsert

Update or set a value on the given object with the given key path.

Params

  • obj {Object}: Object to update/set.
  • path {String}: Key path to update/set.
  • value {*}: Value to update/set.
  • returns {Object}: Update object.

Example

var obj = {};
upsert(obj, 'a.b.c', 'foo');
//=> {a: {b: {c: 'foo'}}}

Related projects

  • has-value: Returns true if a value exists, false if empty. Works with deeply nested values using… more
  • put-value: Update only existing values fromn an object, works with dot notation paths like a.b.c and… more
  • set-value: Create nested values and any intermediaries using dot notation ('a.b.c') paths.

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Brian Woodward

License

Copyright © 2015 Brian Woodward Released under the MIT license.


This file was generated by verb-cli on July 09, 2015.

Current Tags

  • 0.1.0                                ...           latest (11 years ago)

1 Versions

  • 0.1.0                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (4)
Dev Dependencies (1)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |