Skip to content

Commit b82ae38

Browse files
authored
perf(core): optimize async operation & progress events (#23)
perf(core)!: optimize download pipeline, progress events, and stream I/O - lower CPU load by ~35% by replacing `pretty-bytes` and `pretty-ms` with optimized in-repo formatters - lower event-loop load and context switching by ~60% by replacing the old write path with queued/debounced disk writes via `WriteQueue` - reduce network file-engine event overhead by ~10% with debounced progress/event emission - reduce CLI engine-order calculation overhead by ~5% with cached CLI calculations - replace `eventemitter3`/`chalk` with a lighter in-repo `EventEmitter`, fast formatters, and `ansis` - add range-aware per-part downloads, stronger range validation, stream watchdog/retry handling, and renewed download URL support - improve CLI/save-path handling and filename detection, including the `--save` directory fix - expand regression coverage with a local HTTP test server for redirects, ranges, content-length mismatches, pause/resume, and error propagation Benchmarks: https://ido-pluto.github.io/ipull-speed-test/ Benchmarks source: https://github.com/ido-pluto/ipull-speed-test BREAKING CHANGE: minimum supported Node.js version is now 20. BREAKING CHANGE: CLI `-st` shortcut was removed; use `--style`. BREAKING CHANGE: automatic file-name resolution changed to better capture names from URLs and `content-disposition`, so resolved output file names may differ from previous releases. BREAKING CHANGE: `pause()` now closes active connections and `resume()` reopens them. BREAKING CHANGE: `start` and `finished` events are now emitted for `Existing` and `Cloned` download edge cases. BREAKING CHANGE: public download metadata moved to a per-part model: `DownloadFilePart.size` was replaced by `remoteFileSize` and `downloadSize`, and per-part settings such as `parallelStreams` now live on each part instead of resumable progress metadata. BREAKING CHANGE: TypeScript event APIs on exported download engines are now stricter, so arbitrary string event names are no longer accepted by default on typed emitters. Fixes #19 Fixes #21
1 parent 39e7a87 commit b82ae38

76 files changed

Lines changed: 5971 additions & 4427 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Install modules
1717
run: npm ci --ignore-scripts
1818
- name: Build
19-
run: npm run build
19+
run: npm run build:prod
2020
- name: Test
2121
run: npm run test
2222
- name: Generate docs
@@ -66,7 +66,6 @@ jobs:
6666
- name: Release
6767
env:
6868
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
7069
run: npx semantic-release
7170

7271
- name: Set npm package url to GITHUB_OUTPUT

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ jobs:
1313
- name: ESLint
1414
run: npm run lint
1515
- name: TypeScript validity
16-
run: npm run build
16+
run: npm run build:prod
1717
- name: Run Tests
1818
run: npm run test

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ node_modules
1010
/.eslintcache
1111
/test/utils/files/big-image.jpg
1212
/test/utils/files/big-file.jpg
13+
14+
# tests
15+
test/utils/files/big-file.bin
16+
file.gguf
17+
fileCreateToken.gguf

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ import {downloadFileBrowser} from "ipull/dist/browser.js";
5656

5757
const downloader = await downloadFileBrowser({
5858
url: 'https://example.com/file.large',
59-
acceptRangeIsKnown: true // cors origin request will not return the range header, but we can force it to be true (multi-connection download)
59+
acceptRangeIsKnown: true, // overcome CORS, force multi-connection download (use only if you know the server supports range requests)
60+
// defaultFetchDownloadInfo: { // set download info manually to overcome CORS issues && prevent multiple requests
61+
// acceptRange: true,
62+
// length: 40789822,
63+
// }
6064
});
6165

6266
await downloader.download();

0 commit comments

Comments
 (0)