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

Function computeValue

src/compute-engine/boxed-expression/rules.ts:1194–1207  ·  view source on GitHub ↗
(result: Expression)

Source from the content-addressed store, hash-verified

1192
1193 //@note: '.subs()' acts like an expr. 'clone' here (in case of an empty substitution)
1194 // An exception thrown by a `replace` *function* is treated exactly like a
1195 // condition exception handled by `matchRule`: log it and skip this rule
1196 // rather than aborting the `replace()` pass. Deadline cancellations still
1197 // propagate.
1198 let result: Expression | RuleStep | null | undefined;
1199 try {
1200 result =
1201 typeof replace === 'function'
1202 ? replace(expr, sub)
1203 : // @todo: 'expr.subs()' to eventually also assume a 'form' option
1204 // : replace.subs(sub, { form: dynamicForm ? undefined : formValue });
1205 replace.subs(sub, { canonical: getFormType() === 'canonical' });
1206 } catch (e) {
1207 if (e instanceof CancellationError) throw e;
1208 console.error(
1209 `\n| Rule "${rule.id}"\n| Error while applying replacement\n| ${
1210 e instanceof Error ? e.message : e

Callers 1

applyRuleFunction · 0.85

Calls 2

getFormTypeFunction · 0.85
exprMethod · 0.65

Tested by

no test coverage detected