unbox
v1.2.0
Published
Get or set values on an object from a a dot notated string or an array of keys.
Downloads
1,676
Readme
unbox
Get or set values on an object from an array of keys.
Usage
has(object, pathArray/dotNotation)
var has = require('unbox/has');
var myObject = {
a: {
b: 1
}
};
has(myObject, 'a.b'); // true
// OR
has(myObject, ['a', 'b']); // true
has(myObject, 'a.b.c'); // false
get(object, pathArray/dotNotation)
var get = require('unbox/get');
var myObject = {
a: {
b: 1
}
};
get(myObject, 'a.b'); // 1
// OR
get(myObject, ['a', 'b']); // 1
set(object, pathArray/dotNotation, value)
var set = require('unbox/set');
set(myObject, 'a.b.c', 2);
// OR
set(myObject, ['a', 'b', 'c'], 2);
myObject will now be:
{
a: {
b: {
c: 2
}
}
}