* Format bytes to human readable size
(bytes: number)
| 1128 | * Format bytes to human readable size |
| 1129 | */ |
| 1130 | function prettySize(bytes: number): string { |
| 1131 | if (bytes === 0) return '0 Bytes' |
| 1132 | |
| 1133 | const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'] |
| 1134 | const i = Math.floor(Math.log(bytes) / Math.log(1024)) |
| 1135 | |
| 1136 | return `${Number.parseFloat((bytes / 1024 ** i).toFixed(2))} ${sizes[i]}` |
| 1137 | } |
| 1138 | |
| 1139 | /** |
| 1140 | * Create a formatted message for PDF content |
no test coverage detected