Sha256: b70e6ec493c91687edeb4059a4da64268405fba163ed262a46bfbfb4796c096c
Contents?: true
Size: 581 Bytes
Versions: 54
Compression:
Stored size: 581 Bytes
Contents
'use strict'; var GetIntrinsic = require('get-intrinsic'); var $BigInt = GetIntrinsic('%BigInt%', true); var $TypeError = GetIntrinsic('%TypeError%'); var $SyntaxError = GetIntrinsic('%SyntaxError%'); // https://262.ecma-international.org/11.0/#sec-stringtobigint module.exports = function StringToBigInt(argument) { if (typeof argument !== 'string') { throw new $TypeError('`argument` must be a string'); } if (!$BigInt) { throw new $SyntaxError('BigInts are not supported in this environment'); } try { return $BigInt(argument); } catch (e) { return NaN; } };
Version data entries
54 entries across 27 versions & 2 rubygems