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

Function errorCode

test/compute-engine/latex-syntax/errors.test.ts:16–28  ·  view source on GitHub ↗
(expr: ErrorExpressionObject)

Source from the content-addressed store, hash-verified

14};
15
16function errorCode(expr: ErrorExpressionObject): string | undefined {
17 const code = expr.fn[1];
18 if (typeof code === 'string') return code.replace(/^'|'$/g, '');
19 if (code && typeof code === 'object' && !Array.isArray(code) && 'str' in code)
20 return code.str.replace(/^'|'$/g, '');
21 if (Array.isArray(code) && code[0] === 'ErrorCode') {
22 const head = code[1];
23 if (typeof head === 'string') return head.replace(/^'|'$/g, '');
24 if (head && typeof head === 'object' && 'str' in head)
25 return head.str.replace(/^'|'$/g, '');
26 }
27 return undefined;
28}
29
30function collectErrors(expr: MathJsonExpression): ErrorExpressionObject[] {
31 const result: ErrorExpressionObject[] = [];

Callers 1

findErrorFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected