toString.js 427 B

123456789101112131415161718
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $String = GetIntrinsic('%String%');
  4. var $TypeError = GetIntrinsic('%TypeError%');
  5. var Type = require('../Type');
  6. // https://262.ecma-international.org/11.0/#sec-numeric-types-number-tostring
  7. module.exports = function NumberToString(x) {
  8. if (Type(x) !== 'Number') {
  9. throw new $TypeError('Assertion failed: `x` must be a Number');
  10. }
  11. return $String(x);
  12. };