source: imaps-frontend/node_modules/es-abstract/2023/Number/toString.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 654 bytes
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var callBound = require('call-bind/callBound');
6
7var $numberToString = callBound('Number.prototype.toString');
8
9var isInteger = require('../../helpers/isInteger');
10
11// https://262.ecma-international.org/14.0/#sec-numeric-types-number-tostring
12
13module.exports = function NumberToString(x, radix) {
14 if (typeof x !== 'number') {
15 throw new $TypeError('Assertion failed: `x` must be a Number');
16 }
17 if (!isInteger(radix) || radix < 2 || radix > 36) {
18 throw new $TypeError('Assertion failed: `radix` must be an integer >= 2 and <= 36');
19 }
20
21 return $numberToString(x, radix); // steps 1 - 12
22};
Note: See TracBrowser for help on using the repository browser.