ToString.js 396 B

123456789101112131415
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $String = GetIntrinsic('%String%');
  4. var $TypeError = GetIntrinsic('%TypeError%');
  5. // https://ecma-international.org/ecma-262/6.0/#sec-tostring
  6. module.exports = function ToString(argument) {
  7. if (typeof argument === 'symbol') {
  8. throw new $TypeError('Cannot convert a Symbol value to a string');
  9. }
  10. return $String(argument);
  11. };