toString.js 394 B

12345678910111213141516
  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/11.0/#sec-numeric-types-number-tostring
  6. module.exports = function NumberToString(x) {
  7. if (typeof x !== 'number') {
  8. throw new $TypeError('Assertion failed: `x` must be a Number');
  9. }
  10. return $String(x);
  11. };