Function mozjs::jsapi::JS::StringToBigInt

source ·
pub unsafe extern "C" fn StringToBigInt(
    cx: *mut JSContext,
    chars: *const Range<u8>,
) -> *mut BigInt
Expand description

Create a BigInt by parsing a string using the ECMAScript StringToBigInt algorithm (https://tc39.es/ecma262/#sec-stringtobigint). Latin1 and two-byte character ranges are supported. It may be convenient to use JS::ConstLatin1Chars or JS::ConstTwoByteChars.

(StringToBigInt performs parsing similar to that performed by the |Number| global function when passed a string, but it doesn’t allow infinities, decimal points, or exponential notation, and neither algorithm allows numeric separators or an ‘n’ suffix character. This fast-and-loose description is offered purely as a convenience to the reader: see the specification algorithm for exact behavior.)

If parsing fails, this function returns null and throws an exception.