MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / matchesNumber

Function matchesNumber

src/math-json/utils.ts:501–512  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

499
500/** True if the string matches the expected pattern for a number */
501export function matchesNumber(s: string): boolean {
502 return (
503 /^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(s) ||
504 // Optional fraction part where, after the decimal point, at least one of
505 // {fractional digits, repeating-decimal group} is present. This accepts the
506 // digit-less repetend form `0.(3)` (per the MathJSON spec's `1.(3)` example)
507 // while still rejecting a bare trailing `.` (e.g. `5.`).
508 /^[+-]?(0|[1-9][0-9]*)(\.([0-9]+(\([0-9]+\))?|\([0-9]+\)))?([eE][+-]?[0-9]+)?$/.test(
509 s
510 )
511 );
512}
513
514/** True if the string matches the expected pattern for a symbol */
515export function matchesSymbol(s: string): boolean {

Callers 8

serializeExpressionFunction · 0.90
boxFunction · 0.90
serializeJsonStringFunction · 0.90
parseFunction · 0.90
isNumberExpressionFunction · 0.85
stringValueFunction · 0.85
machineValueFunction · 0.85
matchesStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected