source: imaps-frontend/node_modules/es-abstract/2020/NumberToBigInt.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 792 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');
9var isInteger = require('math-intrinsics/isInteger');
10
11// https://262.ecma-international.org/11.0/#sec-numbertobigint
12
13module.exports = function NumberToBigInt(number) {
14 if (typeof number !== 'number') {
15 throw new $TypeError('Assertion failed: `number` must be a String');
16 }
17 if (!isInteger(number)) {
18 throw new $RangeError('The number ' + number + ' cannot be converted to a BigInt because it is not an integer');
19 }
20 if (!$BigInt) {
21 throw new $SyntaxError('BigInts are not supported in this environment');
22 }
23 return $BigInt(number);
24};
Note: See TracBrowser for help on using the repository browser.