MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / formatTokens

Function formatTokens

apps/vis/web/src/util/time.ts:46–51  ·  view source on GitHub ↗
(n: number | null | undefined)

Source from the content-addressed store, hash-verified

44
45/** Format a token count compactly (e.g. "512", "12.4k", "1.20M"). */
46export function formatTokens(n: number | null | undefined): string {
47 if (n === null || n === undefined || !Number.isFinite(n)) return '—';
48 if (n < 1000) return String(n);
49 if (n < 1_000_000) return `${(n / 1000).toFixed(1)}k`;
50 return `${(n / 1_000_000).toFixed(2)}M`;
51}

Callers 4

SummaryGridFunction · 0.90
ContextSparklineFunction · 0.90
TurnCardFunction · 0.90
StepRowFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected