SymbolDescriptiveString.js 521 B

1234567891011121314151617181920
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var callBound = require('call-bind/callBound');
  5. var $SymbolToString = callBound('Symbol.prototype.toString', true);
  6. var Type = require('./Type');
  7. // https://262.ecma-international.org/6.0/#sec-symboldescriptivestring
  8. module.exports = function SymbolDescriptiveString(sym) {
  9. if (Type(sym) !== 'Symbol') {
  10. throw new $TypeError('Assertion failed: `sym` must be a Symbol');
  11. }
  12. return $SymbolToString(sym);
  13. };