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

Function collectErrors

test/compute-engine/latex-syntax/errors.test.ts:30–49  ·  view source on GitHub ↗
(expr: MathJsonExpression)

Source from the content-addressed store, hash-verified

28}
29
30function collectErrors(expr: MathJsonExpression): ErrorExpressionObject[] {
31 const result: ErrorExpressionObject[] = [];
32
33 function visit(x: MathJsonExpression): void {
34 if (Array.isArray(x)) {
35 if (x[0] === 'Error')
36 result.push({ fn: x as ErrorExpressionObject['fn'] });
37 for (const child of x.slice(1)) visit(child);
38 return;
39 }
40
41 if (x && typeof x === 'object' && 'fn' in x) {
42 if (x.fn[0] === 'Error') result.push(x as ErrorExpressionObject);
43 for (const child of x.fn.slice(1)) visit(child);
44 }
45 }
46
47 visit(expr);
48 return result;
49}
50
51function findError(
52 expr: MathJsonExpression,

Callers 1

findErrorFunction · 0.70

Calls 1

visitFunction · 0.70

Tested by

no test coverage detected