| 1 | export function humanFileSize(size: number) { |
| 2 | if (size < 1024) return `${size} B` |
| 3 | let i = Math.min(4, Math.floor(Math.log(size) / Math.log(1024))) |
| 4 | return `${(size / Math.pow(1024, i)).toFixed(2)} ${["B", "KiB", "MiB", "GiB", "TiB"][i]}` |
| 5 | } |
| 6 | |