index.js 392 B

1234567891011121314151617181920
  1. 'use strict';
  2. module.exports = object => {
  3. if (typeof object !== 'object' || object === null) {
  4. throw new TypeError('Expected an object');
  5. }
  6. const result = {};
  7. for (const [key, value] of Object.entries(object)) {
  8. result[value] = key;
  9. }
  10. for (const symbol of Object.getOwnPropertySymbols(object)) {
  11. const value = object[symbol];
  12. result[value] = symbol;
  13. }
  14. return result;
  15. };