SurfSense/surfsense_web/lib/playground/format.ts
2026-07-06 16:45:04 -07:00

13 lines
466 B
TypeScript

/** Formatting helpers shared by the playground runs table and runner output. */
export function formatCost(costMicros: number | null | undefined): string {
if (costMicros == null) return "—";
if (costMicros === 0) return "Free";
return `$${(costMicros / 1_000_000).toFixed(4)}`;
}
export function formatDuration(ms: number | null | undefined): string {
if (ms == null) return "—";
if (ms < 1000) return `${ms}ms`;
return `${(ms / 1000).toFixed(1)}s`;
}