Small, dependency-free formatting helpers for the dashboard: human durations, counts, rates, and percentages. Pure functions, easy to unit-test.
Summary
Functions
Compact integer count (1.2k, 3.4M).
Render a millisecond duration coarsely (largest unit only).
A latency in ms rendered with a unit (sub-ms shown in µs).
A 0.0–1.0 fraction as an integer percentage.
A per-second rate, one decimal place.
Render an uptime from a monotonic started_at (ms) relative to now (ms,
defaults to the current monotonic clock). Coarse on purpose — "3d", "4h",
"12m", "5s", or "just now".
Functions
Compact integer count (1.2k, 3.4M).
Render a millisecond duration coarsely (largest unit only).
A latency in ms rendered with a unit (sub-ms shown in µs).
A 0.0–1.0 fraction as an integer percentage.
A per-second rate, one decimal place.
Render an uptime from a monotonic started_at (ms) relative to now (ms,
defaults to the current monotonic clock). Coarse on purpose — "3d", "4h",
"12m", "5s", or "just now".