1.0.0 • Published 7 years ago

setx v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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]