https://github.com/doowb/upsert-value
Update or set nested values and any intermediaries with dot notation (`'a.b.c'`) paths.
https://github.com/doowb/upsert-value
Last synced: about 1 month ago
JSON representation
Update or set nested values and any intermediaries with dot notation (`'a.b.c'`) paths.
- Host: GitHub
- URL: https://github.com/doowb/upsert-value
- Owner: doowb
- License: mit
- Created: 2015-07-09T20:24:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-16T03:09:09.000Z (over 9 years ago)
- Last Synced: 2024-10-04T03:21:19.721Z (7 months ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# upsert-value [](http://badge.fury.io/js/upsert-value) [](https://travis-ci.org/doowb/upsert-value)
> Update or set nested values and any intermediaries with dot notation (`'a.b.c'`) paths.
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i upsert-value --save
```## Usage
```js
var upsert = require('upsert-value');
```## API
### [upsert](index.js#L32)
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**
```js
var obj = {};
upsert(obj, 'a.b.c', 'foo');
//=> {a: {b: {c: 'foo'}}}
```## Related projects
* [has-own-deep](https://github.com/jonschlinkert/has-own-deep): Returns true if an object has an own, nested property using dot notation paths ('a.b.c').
* [put-value](https://github.com/tunnckocore/put-value#readme): Update only existing values from an object, works with dot notation paths like ` a.b.c` and… [more](https://github.com/tunnckocore/put-value#readme)
* [set-value](https://github.com/jonschlinkert/set-value): Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths.## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/doowb/upsert-value/issues/new)
## Author
**Brian Woodward**
+ [github/doowb](https://github.com/doowb)
+ [twitter/doowb](http://twitter.com/doowb)## License
Copyright © 2015 Brian Woodward
Released under the MIT license.***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 09, 2015._