No Description

invert.js 325B

12345678910111213
  1. var keys = require('./keys.js');
  2. // Invert the keys and values of an object. The values must be serializable.
  3. function invert(obj) {
  4. var result = {};
  5. var _keys = keys(obj);
  6. for (var i = 0, length = _keys.length; i < length; i++) {
  7. result[obj[_keys[i]]] = _keys[i];
  8. }
  9. return result;
  10. }
  11. module.exports = invert;