KeyForSymbol.js 394 B

12345678910111213141516
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var callBound = require('call-bind/callBound');
  4. var $keyFor = callBound('Symbol.keyFor', true);
  5. // https://262.ecma-international.org/14.0/#sec-keyforsymbol
  6. module.exports = function KeyForSymbol(sym) {
  7. if (typeof sym !== 'symbol') {
  8. throw new $TypeError('Assertion failed: `sym` must be a Symbol');
  9. }
  10. return $keyFor(sym);
  11. };