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

Function parsePrefixedUnit

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

* Try to split `symbol` into an SI prefix + a prefixable base unit. * * Strategy: try a 2-character prefix first (e.g. "da"), then 1-character. * The remaining suffix must be a member of `PREFIXABLE_UNITS`. * * Returns `{ prefix, prefixScale, baseEntry }` or `null`.

(
  symbol: string
)

Source from the content-addressed store, hash-verified

240 );
241}
242
243export function isDimensionless(dim: DimensionVector): boolean {
244 return (
245 dim[0] === 0 &&
246 dim[1] === 0 &&
247 dim[2] === 0 &&
248 dim[3] === 0 &&
249 dim[4] === 0 &&
250 dim[5] === 0 &&
251 dim[6] === 0 &&
252 dim[7] === 0
253 );
254}
255
256/**
257 * Try to split `symbol` into an SI prefix + a prefixable base unit.
258 *
259 * Strategy: try a 2-character prefix first (e.g. "da"), then 1-character.
260 * The remaining suffix must be a member of `PREFIXABLE_UNITS`.
261 *
262 * Returns `{ prefix, prefixScale, baseEntry }` or `null`.
263 */
264function parsePrefixedUnit(
265 symbol: string
266): { prefixScale: number; baseEntry: UnitEntry } | null {
267 // Try 2-char prefix first (only "da" currently, but future-proof)
268 if (symbol.length > 2) {
269 const p2 = symbol.slice(0, 2);

Callers 1

resolveUnitFunction · 0.85

Calls 2

sliceMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected