source: imaps-frontend/node_modules/es-abstract/2023/NumberToBigInt.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 800 bytes
Line 
1'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $BigInt = GetIntrinsic('%BigInt%', true);
6var $RangeError = require('es-errors/range');
7var $SyntaxError = require('es-errors/syntax');
8var $TypeError = require('es-errors/type');
9
10var IsIntegralNumber = require('./IsIntegralNumber');
11
12// https://262.ecma-international.org/12.0/#sec-numbertobigint
13
14module.exports = function NumberToBigInt(number) {
15 if (typeof number !== 'number') {
16 throw new $TypeError('Assertion failed: `number` must be a String');
17 }
18 if (!IsIntegralNumber(number)) {
19 throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer');
20 }
21 if (!$BigInt) {
22 throw new $SyntaxError('BigInts are not supported in this environment');
23 }
24 return $BigInt(number);
25};
Note: See TracBrowser for help on using the repository browser.