split-keys
v0.0.7
Published
For each comma-separated key in object create a separate property.
Downloads
1,478
Maintainers
Readme
Split Keys
Gracefully declare properties aliases within objects. Split-keys splits comma-separated keys in object and for each key creates property alias.
Before:
var a = {
x: {
a: 1,
b: 1
}
};
//create alias
a.y = a.x;
After:
//declare list of aliases
var a = splitKeys({
'x, y': {
a: 1,
b: 1
}
});
Use
$ npm install split-keys
var splitKeys = require('split-keys');
var obj = splitKeys({
'a, b': function(){}
});
obj.a === obj.b //true
API
splitKeys(object)
— split comma-separated propertiessplitKeys(object, deep)
— split comma-separated properties, including inner objectssplitKeys(object, separator)
— apply custom separator to split. Separator can be whether a string or a RegExp.splitKeys(object, separator, deep)
orsplitKeys(object, deep, separator)
— apply custom separator to deep split keys