blob: 4d494e1e238bef063f30e02fbce66a11d7cfbb1c [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $String = GetIntrinsic('%String%');
6var $TypeError = GetIntrinsic('%TypeError%');
7
8// https://ecma-international.org/ecma-262/6.0/#sec-tostring
9
10module.exports = function ToString(argument) {
11 if (typeof argument === 'symbol') {
12 throw new $TypeError('Cannot convert a Symbol value to a string');
13 }
14 return $String(argument);
15};