Urara-Blog/node_modules/.pnpm-store/v3/files/f5/ba08afb4e02d5259670bfaa150dc85ef34c5325cfd168e3ec2bffd1c76857ff7927a2fcd027ccde5320cdecc1e403ed20c98c3a54d18d3b212c072450f361c
2022-08-14 01:14:53 +08:00

26 lines
814 B
Text

'use strict';
var GetIntrinsic = require('get-intrinsic');
var $BigInt = GetIntrinsic('%BigInt%', true);
var $RangeError = GetIntrinsic('%RangeError%');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var $TypeError = GetIntrinsic('%TypeError%');
var IsInteger = require('./IsInteger');
var Type = require('./Type');
// https://262.ecma-international.org/11.0/#sec-numbertobigint
module.exports = function NumberToBigInt(number) {
if (Type(number) !== 'Number') {
throw new $TypeError('Assertion failed: `number` must be a String');
}
if (!IsInteger(number)) {
throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer');
}
if (!$BigInt) {
throw new $SyntaxError('BigInts are not supported in this environment');
}
return $BigInt(number);
};