Speed up downloads by combining multiple network connections in parallel
TypeScript bandwidth-aggregationcross-platformdesktop-appdownloaderdownloadmanagerlinuxmacosmulticonnectionparallel-downloadswindows
Show "1m 0s" rather than "60s" for a time left just under a minute (#149)
Arpit Khandelwalfd22a8860557
diff --git a/e2e/format.spec.ts b/e2e/format.spec.tsindex e2a8b54..f2e5280 100644--- a/e2e/format.spec.ts+++ b/e2e/format.spec.ts@@ -1,6 +1,7 @@import { expect, test } from '@playwright/test'import {formatBytes,+ formatEta,formatPercent,formatSpeed,speedTicks@@ -32,4 +33,12 @@ test.describe('formatting @smoke', () => {expect(ticks.length).toBeGreaterThan(0)for (const tick of ticks) expect(tick.label).toMatch(/ B\/s$/)})++ test('a countdown never reads 60s', () => {+ expect(formatEta(0.2)).toBe('1s')+ expect(formatEta(58.2)).toBe('59s')+ expect(formatEta(59.01)).toBe('1m 0s')+ expect(formatEta(59.5)).toBe('1m 0s')+ expect(formatEta(61)).toBe('1m 1s')+ })})diff --git a/src/renderer/src/utils/format.ts b/src/renderer/src/utils/format.tsindex 8364f99..71819c3 100644--- a/src/renderer/src/utils/format.ts+++ b/src/renderer/src/utils/format.ts@@ -113,8 +113,9 @@ export function formatSpeedOfLimit(export function formatEta(seconds: number): string {if (!Number.isFinite(seconds) || seconds <= 0) return '—'- if (seconds < 60) return `${Math.max(1, Math.ceil(seconds))}s`- const totalSec = Math.round(seconds)+ // Seconds round up, so anything past 59s is a minute: "1m 0s", never "60s".+ if (Math.ceil(seconds) < 60) return `${Math.max(1, Math.ceil(seconds))}s`+ const totalSec = Math.max(60, Math.round(seconds))const mins = Math.floor(totalSec / 60)const secs = totalSec % 60if (mins < 60) return `${mins}m ${secs}s`