MCPcopy Create free account
hub / github.com/effect-app/libs / factorExpr

Function factorExpr

packages/infra/src/Store/Cosmos/query.ts:354–360  ·  view source on GitHub ↗
(unitExpr: string, toBase: string, factors: Readonly<Record<string, number>>)

Source from the content-addressed store, hash-verified

352 }
353 }
354 const factorExpr = (unitExpr: string, toBase: string, factors: Readonly<Record<string, number>>) => {
355 const entries = Object.entries(factors).filter(([, factor]) => Number.isFinite(factor))
356 return entries.reduceRight<string>(
357 (acc, [unit, factor]) => `IIF(${unitExpr} = ${JSON.stringify(unit)}, ${factor}, ${acc})`,
358 `IIF(${unitExpr} = ${JSON.stringify(toBase)}, 1, 0)`
359 )
360 }
361 const filter = "filter" in computed ? computed.filter : []
362 // Print filter once — `print` mutates the outer `i` parameter counter, so
363 // re-walking the same filter would double-bump it and desync @v indices.

Callers 1

computedSelectExprFunction · 0.85

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…