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

25 lines
631 B
Text

'use strict';
var GetIntrinsic = require('get-intrinsic');
var $BigInt = GetIntrinsic('%BigInt%', true);
var $asIntN = GetIntrinsic('%BigInt.asIntN%', true);
var $Number = GetIntrinsic('%Number%');
var $SyntaxError = GetIntrinsic('%SyntaxError%');
var ToPrimitive = require('./ToPrimitive');
// https://262.ecma-international.org/11.0/#sec-tobigint
module.exports = function ToBigInt(argument) {
if (!$BigInt) {
throw new $SyntaxError('BigInts are not supported in this environment');
}
var prim = ToPrimitive(argument, $Number);
if (typeof prim === 'number') {
return $asIntN(0, prim);
}
return $BigInt(prim);
};