(bytes)
| 24 | } |
| 25 | |
| 26 | function formatBytes(bytes) { |
| 27 | if (!Number.isFinite(bytes) || bytes < 0) return '0 B'; |
| 28 | if (bytes < 1024) return `${Math.round(bytes)} B`; |
| 29 | if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; |
| 30 | if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; |
| 31 | return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`; |
| 32 | } |
| 33 | |
| 34 | function formatSpeed(bps) { |
| 35 | return `${formatBytes(bps)}/s`; |
no outgoing calls
no test coverage detected