a20966c5f82733da948ade369d53e2cb40e4ea3f7118c97191c1ed98e6063b347efbaf24aed649f1c971e624c528654561a3c038a905a4d0bf1eecd36bc137 588 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $BigInt = GetIntrinsic('%BigInt%', true);
  4. var $TypeError = require('es-errors/type');
  5. var $SyntaxError = require('es-errors/syntax');
  6. // https://262.ecma-international.org/14.0/#sec-stringtobigint
  7. module.exports = function StringToBigInt(argument) {
  8. if (typeof argument !== 'string') {
  9. throw new $TypeError('`argument` must be a string');
  10. }
  11. if (!$BigInt) {
  12. throw new $SyntaxError('BigInts are not supported in this environment');
  13. }
  14. try {
  15. return $BigInt(argument);
  16. } catch (e) {
  17. return void undefined;
  18. }
  19. };