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

Function parseUnitToken

src/compute-engine/numerics/unit-data.ts:514–524  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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];

Callers 1

parseDSLGroupFunction · 0.85

Calls 2

isNaNFunction · 0.85
sliceMethod · 0.65

Tested by

no test coverage detected