main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
782 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $SyntaxError = require('es-errors/syntax');
|
---|
| 4 | var $TypeError = require('es-errors/type');
|
---|
[79a0317] | 5 | var callBound = require('call-bound');
|
---|
| 6 | var isInteger = require('math-intrinsics/isInteger');
|
---|
[d565449] | 7 |
|
---|
| 8 | var $BigIntToString = callBound('BigInt.prototype.toString', true);
|
---|
| 9 |
|
---|
| 10 | // https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-tostring
|
---|
| 11 |
|
---|
| 12 | module.exports = function BigIntToString(x, radix) {
|
---|
| 13 | if (typeof x !== 'bigint') {
|
---|
| 14 | throw new $TypeError('Assertion failed: `x` must be a BigInt');
|
---|
| 15 | }
|
---|
| 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 | if (!$BigIntToString) {
|
---|
| 22 | throw new $SyntaxError('BigInt is not supported');
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | return $BigIntToString(x, radix); // steps 1 - 12
|
---|
| 26 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.