setx
v1.0.0
Published
Set deeply into an object given an array of keys
Downloads
5
Readme
setx
Set deep into an object given an array of keys.
api
setx (object, any, array[string]) -> obj
install
npm install setx --save
usage
var setx = require('setx')
var obj = { x: { foo: 1, bar: 2, baz: [() => 1] } }
var keyPath = ['x', 'y', 'z']
var value = [1,2,3,4]
var o = setx(obj, value, keyPath)
o.x.y.z // [1,2,3,4]