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:
791 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var $SyntaxError = require('es-errors/syntax');
|
---|
4 | var $TypeError = require('es-errors/type');
|
---|
5 |
|
---|
6 | var callBound = require('call-bind/callBound');
|
---|
7 |
|
---|
8 | var $BigIntToString = callBound('BigInt.prototype.toString', true);
|
---|
9 |
|
---|
10 | var isInteger = require('../../helpers/isInteger');
|
---|
11 |
|
---|
12 | // https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-tostring
|
---|
13 |
|
---|
14 | module.exports = function BigIntToString(x, radix) {
|
---|
15 | if (typeof x !== 'bigint') {
|
---|
16 | throw new $TypeError('Assertion failed: `x` must be a BigInt');
|
---|
17 | }
|
---|
18 |
|
---|
19 | if (!isInteger(radix) || radix < 2 || radix > 36) {
|
---|
20 | throw new $TypeError('Assertion failed: `radix` must be an integer >= 2 and <= 36');
|
---|
21 | }
|
---|
22 |
|
---|
23 | if (!$BigIntToString) {
|
---|
24 | throw new $SyntaxError('BigInt is not supported');
|
---|
25 | }
|
---|
26 |
|
---|
27 | return $BigIntToString(x, radix); // steps 1 - 12
|
---|
28 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.