mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-10 22:32:16 +02:00
14 lines
466 B
TypeScript
14 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`;
|
||
|
|
}
|