index.js 229 B

123456789101112131415
  1. 'use strict';
  2. module.exports = function (obj) {
  3. if (typeof obj !== 'object') {
  4. throw new TypeError('Expected an object');
  5. }
  6. var ret = {};
  7. for (var key in obj) {
  8. var val = obj[key];
  9. ret[val] = key;
  10. }
  11. return ret;
  12. };