$ cnpm install obj-util
A simple helper to set/get keys from objects using a string path like 'some.key.here'
npm i --save obj-util
Returns the value from the given object which matches the passed key
key1.subkey1.subsubkey1var objUtil = require('obj-util');
var obj = {
some: {
key: 'some value'
}
};
// getKeyValue
objUtil.getKeyValue(obj, 'some.key'); // 'some value'
Sets a value in an object if a matching key is found inside the given object
var objUtil = require('obj-util');
var obj = {
};
objUtil.setKeyValue(obj, 'some.key', 'some value');
obj.some.key === 'some value' //==> true
That's it!
Copyright 2013 - present © cnpmjs.org | Home |