|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
782 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var $SyntaxError = require('es-errors/syntax');
|
|---|
| 4 | var $TypeError = require('es-errors/type');
|
|---|
| 5 | var callBound = require('call-bound');
|
|---|
| 6 | var isInteger = require('math-intrinsics/isInteger');
|
|---|
| 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.