index.js 256 B

123456789101112131415
  1. 'use strict';
  2. module.exports = object => {
  3. if (typeof object !== 'object') {
  4. throw new TypeError('Expected an object');
  5. }
  6. const ret = {};
  7. for (const key of Object.keys(object)) {
  8. const value = object[key];
  9. ret[value] = key;
  10. }
  11. return ret;
  12. };