MCPcopy Index your code
hub / github.com/getagentseal/codeburn / formatTokens

Function formatTokens

src/format.ts:10–18  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

8export { formatCost }
9
10export function formatTokens(n: number): string {
11 // Guard against Infinity / NaN / negatives that would otherwise leak into
12 // the UI as "Infinity" or "NaN" strings when an upstream calculation glitches.
13 if (!Number.isFinite(n)) return '?'
14 if (n < 0) return '0'
15 if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`
16 if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`
17 return Math.round(n).toString()
18}
19
20/// Returns YYYY-MM-DD for the given date in the process-local timezone. Cheaper than shelling
21/// out to Intl.DateTimeFormat for every turn in a loop and avoids the UTC drift that bites

Callers 15

renderAuditTableFunction · 0.70
OverviewFunction · 0.70
ProjectBreakdownFunction · 0.70
FindingPanelFunction · 0.70
OptimizeViewFunction · 0.70
TreeDetailsFunction · 0.70
renderContextTreeFunction · 0.70
detectBloatedClaudeMdFunction · 0.70
detectCacheBloatFunction · 0.70
detectBashBloatFunction · 0.70
detectContextBloatFunction · 0.70
renderFindingFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected