source: imaps-frontend/node_modules/es-abstract/2021/StringToBigInt.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: 577 bytes
Line 
1'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $BigInt = GetIntrinsic('%BigInt%', true);
6var $TypeError = require('es-errors/type');
7var $SyntaxError = require('es-errors/syntax');
8
9// https://262.ecma-international.org/11.0/#sec-stringtobigint
10
11module.exports = function StringToBigInt(argument) {
12 if (typeof argument !== 'string') {
13 throw new $TypeError('`argument` must be a string');
14 }
15 if (!$BigInt) {
16 throw new $SyntaxError('BigInts are not supported in this environment');
17 }
18 try {
19 return $BigInt(argument);
20 } catch (e) {
21 return NaN;
22 }
23};
Note: See TracBrowser for help on using the repository browser.