SymbolDescriptiveString.js 526 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://ecma-international.org/ecma-262/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. };