deep-setter
v1.0.2
Published
sets a value deep in an object
Downloads
415
Maintainers
Readme
deep-setter
sets a value deep in an object
#Install
npm install deep-setter --save
#Usage
var setter = require('deep-setter');
//setter is a function that takes (originObject, deepValueAnnotation, value)
If You:
setter({}, 'an.[@1].arbitrary.[@0].address', 'value')
Result:
{ an : [, { arbitrary : [ { address : 'value'} ] } ] } );
If You:
setter({}, 'an.1.arbitrary.0.address', 'value')
Result:
{ an : { 1 : { arbitrary : { 0 : { address : 'value'} } } } } );
If You:
setter({}, 'an.arbitrary.address', { test : 'value'})
Result:
{ an : { arbitrary : { address : { test : 'value' }} } } );