(expr: math.MathNode)
| 1 | import * as math from 'mathjs' |
| 2 | |
| 3 | export function getSymbols(expr: math.MathNode) { |
| 4 | return expr |
| 5 | .filter((node) => { |
| 6 | if (node instanceof math.SymbolNode && node.isSymbolNode) { |
| 7 | try { |
| 8 | const e = node.evaluate() |
| 9 | return !!e.units |
| 10 | } catch { |
| 11 | return node.name !== 'x' |
| 12 | } |
| 13 | } |
| 14 | return false |
| 15 | }) |
| 16 | .map((node: unknown) => (node as math.SymbolNode).name) |
| 17 | } |
| 18 | |
| 19 | export function parseExpression(expression: string, get: (path: string) => any) { |
| 20 | const parsed = math.parse(expression) |
no outgoing calls
no test coverage detected
searching dependent graphs…