(n: number)
| 63 | const units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; |
| 64 | |
| 65 | function niceBytes(n: number) { |
| 66 | let l = 0; |
| 67 | |
| 68 | while (n >= 1024 && ++l) { |
| 69 | n = n / 1024; |
| 70 | } |
| 71 | |
| 72 | return n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]; |
| 73 | } |