Open History to see the last commit
1/** Latency presets for the fake API, in milliseconds. */
2export const LATENCY_PRESETS = [0, 500, 2000, 5000] as const;
3
4export type LatencyPreset = (typeof LATENCY_PRESETS)[number];
5
6/** `0` → "0 ms", `500` → "500 ms", `2000` → "2 s". */
7export function formatLatency(ms: number): string {
8 return ms < 1000 ? `${ms} ms` : `${ms / 1000} s`;
9}
10
11/** A measured time: `42` → "42 ms", `2013` → "2.0 s". */
12export function formatDuration(ms: number): string {
13 return ms < 1000 ? `${Math.round(ms)} ms` : `${(ms / 1000).toFixed(1)} s`;
14}