kopia lustrzana https://github.com/c9/core
9 wiersze
196 B
JavaScript
9 wiersze
196 B
JavaScript
|
/*
|
||
|
* Swap keys and values of an object
|
||
|
*/
|
||
|
exports.invert = function(obj) {
|
||
|
return Object.keys(obj).reduce(function(res, key) {
|
||
|
res[obj[key]] = key;
|
||
|
return res;
|
||
|
}, {});
|
||
|
};
|