Optional options: { Optional acceptIf true (by default), common invalid numeric literals will also be accepted and marked with options.invalidError.
Optional boundary?: booleanIf true (by default), the numeric literal must have a boundary at the end (non inclusive).
Optional invalidDefault: "invalid numeric literal"
Optional numericGenerated using TypeDoc
Match the literal representations of numbers in JavaScript code.
You can use
Number(token.content.replaceAll(numericSeparator, ''))to get the numeric value. The default numeric separator is_, you can customize it by settingoptions.numericSeparatorto a string.If you want to disable the numeric separator, set
options.numericSeparatortofalse.If
options.acceptInvalidistrue(by default), common invalid numeric literals will also be matched and marked with error.E.g.
423.14151.5e100.123e-40x2a0xFF0o7551_000_0001_000_000.000_0011e6_0000o[0-7]*[^0-7]+: Octal literals that include non-octal characters.0x[\da-f]*[^\da-f]+: Hexadecimal literals that include non-hexadecimal characters.(?:\d+\.){2,}: Numeric literals that include more than one decimal point.\d+\.\.\d+: Numeric literals that include more than one decimal point without any other characters in between.\d+e[+-]?\d+e[+-]?\d+: Numeric literals that include more than one exponent (e or E).\d+e: Numeric literals that end with an exponent but without any digits after the exponent symbol.