blob: 1efd1316b2bb8b30d4133ecd32fd9183678e5dd3 [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $TypeError = GetIntrinsic('%TypeError%');
6
7var callBound = require('call-bind/callBound');
8
9var $SymbolToString = callBound('Symbol.prototype.toString', true);
10
11var Type = require('./Type');
12
13// https://ecma-international.org/ecma-262/6.0/#sec-symboldescriptivestring
14
15module.exports = function SymbolDescriptiveString(sym) {
16 if (Type(sym) !== 'Symbol') {
17 throw new $TypeError('Assertion failed: `sym` must be a Symbol');
18 }
19 return $SymbolToString(sym);
20};