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
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var callBound = require('call-bind/callBound');
|
---|
| 6 |
|
---|
| 7 | var $numberToString = callBound('Number.prototype.toString');
|
---|
| 8 |
|
---|
| 9 | var isInteger = require('../../helpers/isInteger');
|
---|
| 10 |
|
---|
| 11 | // https://262.ecma-international.org/14.0/#sec-numeric-types-number-tostring
|
---|
| 12 |
|
---|
| 13 | module.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.