object-nest

Assign some property nestly

Downloads
25
Stars
3
Committers
1

object-nest Build Status

Assign some property nestly

Installation

npm install --save object-nest

Example

const objectNest = require('object-nest');
// assign an object nestly
var obj = { a: 1 };
obj = objectNest(obj, 'b.c.d', 'hello');
// return Object
{
  a: 1,
  b: {
    c: {
      d: 'hello'
    }
  }
}
//create a new object nestly
obj = objectNest(null, 'a.b.c.d', 'hi');
// obj.a.b.c.d => 'hi'

License

MIT © EGOIST