* Parse a unit token like `"s^2"` into a MathJSON expression. * A plain unit (no `^`) stays as a string; `"s^2"` becomes * `["Power", "s", 2]`.
(token: string)
| 512 | } |
| 513 | return result; |
| 514 | } |
| 515 | |
| 516 | if (op === 'Divide') { |
| 517 | if (expr.length !== 3) return null; |
| 518 | const sa = getExpressionScale(expr[1]); |
| 519 | const sb = getExpressionScale(expr[2]); |
| 520 | if (sa === null || sb === null || sb === 0) return null; |
| 521 | return sa / sb; |
| 522 | } |
| 523 | |
| 524 | if (op === 'Power') { |
| 525 | if (expr.length !== 3) return null; |
| 526 | const s = getExpressionScale(expr[1]); |
| 527 | const exp = expr[2]; |
no test coverage detected