frontend/.pnpm-store/v3/files/a1/cbd6b148986839b021d5ae7822bd3e412750beabe052bb13d5faaa6fb5be16bb39ef394fc4c8425bb2e6c0c628ff8498ce05046986cb034f8c1d1e6b4d7656

24 lines
592 B
Plaintext

'use strict';
var GetIntrinsic = require('get-intrinsic');
var $BigInt = GetIntrinsic('%BigInt%', true);
var $TypeError = GetIntrinsic('%TypeError%');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
// https://262.ecma-international.org/14.0/#sec-stringtobigint
module.exports = function StringToBigInt(argument) {
if (typeof argument !== 'string') {
throw new $TypeError('`argument` must be a string');
}
if (!$BigInt) {
throw new $SyntaxError('BigInts are not supported in this environment');
}
try {
return $BigInt(argument);
} catch (e) {
return void undefined;
}
};