| 1 |
// Pure upload-progress formatting (no DOM), extracted from static/upload.js. |
| 2 |
|
| 3 |
/** Human-readable transfer speed, e.g. "2.4 MB/s" or "740 KB/s". */ |
| 4 |
export function formatSpeed(bytesPerSec: number): string { |
| 5 |
return bytesPerSec > 1024 * 1024 |
| 6 |
? (bytesPerSec / (1024 * 1024)).toFixed(1) + ' MB/s' |
| 7 |
: (bytesPerSec / 1024).toFixed(0) + ' KB/s'; |
| 8 |
} |
| 9 |
|
| 10 |
/** Human-readable ETA, e.g. "45s" or "2m 5s". */ |
| 11 |
export function formatEta(remainingSec: number): string { |
| 12 |
return remainingSec < 60 |
| 13 |
? Math.ceil(remainingSec) + 's' |
| 14 |
: Math.ceil(remainingSec / 60) + 'm ' + Math.ceil(remainingSec % 60) + 's'; |
| 15 |
} |
| 16 |
|