File
Blob: worker/src/client/ui/format.ts
| 1 | export function formatTime(ms: number): string { |
| 2 | const seconds = Math.max(0, Math.floor(ms / 1000)); |
| 3 | return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`; |
| 4 | } |
| 5 | |
| 6 | export function formatBytes(bytes?: number): string { |
| 7 | if (bytes === undefined) return '––'; |
| 8 | return bytes >= 1024 * 1024 |
| 9 | ? `${(bytes / (1024 * 1024)).toFixed(1)} MiB` |
| 10 | : `${(bytes / 1024).toFixed(1)} KiB`; |
| 11 | } |