Permalink
Cannot retrieve contributors at this time
27 lines (21 sloc)
824 Bytes
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/es-abstract/2020/NumberToBigInt.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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 Type = require('./Type'); | |
var isInteger = require('../helpers/isInteger'); | |
// 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); | |
}; |