bigIntParse
bigIntParse(
text,radix?):bigint
Defined in: packages/core/src/big-int/parse.ts:45
Parses text as a bigint in radix — the bigint sibling of parseInt,
and the radix BigInt() never took.
BigInt("ff") throws and there is no BigInt(text, radix), so a bigint
cannot be read from anything but decimal or a 0b/0o/0x literal without
this. Every radix from 2 to 36 is accepted, digits are case-insensitive, and
surrounding whitespace is ignored.
Unlike parseInt this is strict: a character radix does not define
throws rather than silently ending the number, so bigIntParse("12abc") is
an error and not 12n. parseInt reports that case as NaN, which a
bigint has no equivalent of.
A 0b/0o/0x prefix is accepted when it agrees with radix, and selects
one when radix is omitted, matching BigInt(). A sign may precede it.
O(n²/k) for an n-digit input, where k is how many radix digits fit in a
safe integer — the accumulator grows as it goes, the same shape as the
engine’s own decimal conversion.
Parameters
Section titled “Parameters”string
The digits to read, optionally signed and prefixed.
radix?
Section titled “radix?”number
The base, from 2 to 36. Defaults to the prefix’s base, or 10.
Returns
Section titled “Returns”bigint
The value as a bigint.
Throws
Section titled “Throws”If radix is not an integer in [2, 36], or a prefix
contradicts it.
Throws
Section titled “Throws”If text holds no digits, or holds one radix does
not define.