keyarray-set
v1.0.1
Published
set nested properties with key arrays
Downloads
3,160
Maintainers
Readme
var set = require('keyarray-set')
var assert = require('assert')
var anObject = {
a: {
b: {}
}
}
assert(set(anObject, ['a', 'b', 'c'], 'new value') === 'new value')
assert(anObject.a.b.hasOwnProperty('c') === true)
assert(anObject.a.b.c === 'new value')
assert.throws(function () {
set(anObject, ['nonexistent', 'key'], 'another value')
}, TypeError)