(size: number)
| 1 | export const humanFileSize = (size: number): string => { |
| 2 | const units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; |
| 3 | let i = 0; |
| 4 | while (size >= 1024 && i < units.length - 1) { |
| 5 | size /= 1024; |
| 6 | i++; |
| 7 | } |
| 8 | return `${size.toFixed(0)} ${units[i]}`; |
| 9 | } |
no outgoing calls
no test coverage detected