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

Function stringValue

src/math-json/utils.ts:98–108  ·  view source on GitHub ↗
(
  expr: MathJsonExpression | null | undefined
)

Source from the content-addressed store, hash-verified

96 * **U+0027 APOSTROPHE** : **`'`** or an object literal with a `str` key.
97 */
98export function stringValue(
99 expr: MathJsonExpression | null | undefined
100): string | null {
101 if (expr === null || expr === undefined) return null;
102 if (typeof expr === 'object' && 'str' in expr) return expr.str;
103 if (typeof expr !== 'string') return null;
104 if (expr.length >= 2 && expr.at(0) === "'" && expr.at(-1) === "'")
105 return expr.substring(1, expr.length - 1);
106 if (matchesNumber(expr) || matchesSymbol(expr)) return null;
107 return expr;
108}
109
110export function stripText(
111 expr: MathJsonExpression | null | undefined

Callers 15

serializeExpressionFunction · 0.90
serializeCortexFunction · 0.90
expressionToStringFunction · 0.90
boxFunction · 0.90
serializeMethod · 0.90
parseFunction · 0.90
parseTextRunFunction · 0.90
serializeLatexTokensFunction · 0.90
errorContextAsLatexFunction · 0.90

Calls 3

matchesNumberFunction · 0.85
matchesSymbolFunction · 0.85
atMethod · 0.65

Tested by

no test coverage detected