1.0.1 • Published 9 years ago

nested-prop v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

nested-prop Build Status

Get and set nested properties.

Install

$ npm install --save nested-prop

Usage

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