object-nest
v0.1.2
Published
Assign some property nestly
Downloads
141
Readme
object-nest
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