odin-js-fundamentals-part-5/node_modules/es-abstract/2023/KeyForSymbol.js

21 lines
472 B
JavaScript
Raw Normal View History

2024-01-11 08:52:05 +00:00
'use strict';
var GetIntrinsic = require('get-intrinsic');
var $TypeError = GetIntrinsic('%TypeError%');
var callBound = require('call-bind/callBound');
var $keyFor = callBound('Symbol.keyFor', true);
var Type = require('./Type');
// https://262.ecma-international.org/14.0/#sec-keyforsymbol
module.exports = function KeyForSymbol(sym) {
if (Type(sym) !== 'Symbol') {
throw new $TypeError('Assertion failed: `sym` must be a Symbol');
}
return $keyFor(sym);
};