https://github.com/floatdrop/nested-prop
Get and set nested properties
https://github.com/floatdrop/nested-prop
Last synced: about 1 year ago
JSON representation
Get and set nested properties
- Host: GitHub
- URL: https://github.com/floatdrop/nested-prop
- Owner: floatdrop
- License: mit
- Created: 2015-04-07T11:53:06.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-07T12:25:00.000Z (about 11 years ago)
- Last Synced: 2025-03-14T01:31:42.714Z (about 1 year ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# nested-prop [](https://travis-ci.org/floatdrop/nested-prop)
Get and set nested properties.
## Install
```
$ npm install --save nested-prop
```
## Usage
```js
var nestedProp = require('nested-prop');
var obj = {a: ''};
nestedProp.set(obj, 'a.b.c', 1);
//=> {a: {b: {c: 1}}}
nestedProp.get(obj, 'a.b.c');
//=> 1
```
## API
### nestedProp.get(object, path)
Gets property from object by path.
### nestedProp.set(object, path, value)
Sets value to property by path. If some properties is not assignable Objects (like `string`) - they will be overwritten.
## License
MIT © [Vsevolod Strukchinsky](http://github.yandex-team.ru/floatdrop)