ToString.js 389 B

123456789101112131415
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $String = GetIntrinsic('%String%');
  4. var $TypeError = require('es-errors/type');
  5. // https://262.ecma-international.org/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. };