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

Function formatDuration

apps/vis/web/src/util/time.ts:36–43  ·  view source on GitHub ↗
(ms: number | null | undefined)

Source from the content-addressed store, hash-verified

34
35/** Format a duration in ms as a compact human string (e.g. "840ms", "2.4s", "1m03s"). */
36export function formatDuration(ms: number | null | undefined): string {
37 if (ms === null || ms === undefined || !Number.isFinite(ms)) return '—';
38 if (ms < 1000) return `${Math.round(ms)}ms`;
39 if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
40 const m = Math.floor(ms / 60000);
41 const s = Math.floor((ms % 60000) / 1000);
42 return `${m}m${String(s).padStart(2, '0')}s`;
43}
44
45/** Format a token count compactly (e.g. "512", "12.4k", "1.20M"). */
46export function formatTokens(n: number | null | undefined): string {

Callers 7

SummaryGridFunction · 0.90
ToolStatsTableFunction · 0.90
IdleGapsFunction · 0.90
TurnCardFunction · 0.90
StepRowFunction · 0.90
ToolRowFunction · 0.90
PairIndicatorFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected