This commit is contained in:
Lilith 2025-02-27 02:26:55 +01:00
parent a71a3b5593
commit cb52890889
Signed by: lilith
GPG key ID: 8712A0F317C37175
16657 changed files with 1483086 additions and 1 deletions

View file

@ -0,0 +1,28 @@
'use strict';
var $SyntaxError = require('es-errors/syntax');
var $TypeError = require('es-errors/type');
var callBound = require('call-bind/callBound');
var $BigIntToString = callBound('BigInt.prototype.toString', true);
var isInteger = require('../../helpers/isInteger');
// https://262.ecma-international.org/14.0/#sec-numeric-types-bigint-tostring
module.exports = function BigIntToString(x, radix) {
if (typeof x !== 'bigint') {
throw new $TypeError('Assertion failed: `x` must be a BigInt');
}
if (!isInteger(radix) || radix < 2 || radix > 36) {
throw new $TypeError('Assertion failed: `radix` must be an integer >= 2 and <= 36');
}
if (!$BigIntToString) {
throw new $SyntaxError('BigInt is not supported');
}
return $BigIntToString(x, radix); // steps 1 - 12
};