source: imaps-frontend/node_modules/es-abstract/2024/BigInt/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: 791 bytes
RevLine 
[d565449]1'use strict';
2
3var $SyntaxError = require('es-errors/syntax');
4var $TypeError = require('es-errors/type');
5
6var callBound = require('call-bind/callBound');
7
8var $BigIntToString = callBound('BigInt.prototype.toString', true);
9
10var isInteger = require('../../helpers/isInteger');
11
12// https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-tostring
13
14module.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.