| 283 | } |
| 284 | |
| 285 | function formatBytes(bytes: number | null): string | null { |
| 286 | if (bytes == null || !Number.isFinite(bytes) || bytes <= 0) return null |
| 287 | const units = ['B', 'KB', 'MB', 'GB'] |
| 288 | let value = bytes |
| 289 | let unit = units[0] |
| 290 | for (let i = 1; i < units.length && value >= 1024; i += 1) { |
| 291 | value /= 1024 |
| 292 | unit = units[i] |
| 293 | } |
| 294 | const rounded = value >= 100 ? value.toFixed(0) : value >= 10 ? value.toFixed(1) : value.toFixed(2) |
| 295 | return `${rounded} ${unit}` |
| 296 | } |
| 297 | |
| 298 | function formatReleaseNotesForDisplay(notes: string | null): string | null { |
| 299 | if (!notes) return null |