(bytes: number)
| 8 | * don't conflate them. |
| 9 | */ |
| 10 | export function formatBytes(bytes: number): string { |
| 11 | if (bytes < 1024) return `${bytes} B`; |
| 12 | if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KiB`; |
| 13 | if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MiB`; |
| 14 | return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GiB`; |
| 15 | } |