| Leo Repp | 58b9f11 | 2021-11-22 11:57:47 +0100 | [diff] [blame^] | 1 | 'use strict'; |
| 2 | |||||
| 3 | var GetIntrinsic = require('get-intrinsic'); | ||||
| 4 | |||||
| 5 | var $String = GetIntrinsic('%String%'); | ||||
| 6 | var $TypeError = GetIntrinsic('%TypeError%'); | ||||
| 7 | |||||
| 8 | // https://ecma-international.org/ecma-262/6.0/#sec-tostring | ||||
| 9 | |||||
| 10 | module.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 | }; | ||||