uni-ticket-system/node_modules/invert-kv/index.js
2023-12-05 10:11:10 +08:00

21 lines
392 B
JavaScript

'use strict';
module.exports = object => {
if (typeof object !== 'object' || object === null) {
throw new TypeError('Expected an object');
}
const result = {};
for (const [key, value] of Object.entries(object)) {
result[value] = key;
}
for (const symbol of Object.getOwnPropertySymbols(object)) {
const value = object[symbol];
result[value] = symbol;
}
return result;
};