index.js 229 B

12345678910111213141516
  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. };