@zip.js/zip.js 2.8.29 → 2.8.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/BENCHMARKS.md CHANGED
@@ -104,6 +104,41 @@ sequential or "parallel"). Use those backends when a native `CompressionStream`
104
104
  unavailable or when you need byte-identical zlib output; use the native backend when you
105
105
  want this parallelism.
106
106
 
107
+ There is a second way to land on the WASM backend by accident: because
108
+ `CompressionStream` exposes no level control, requesting any non-default compression
109
+ level (e.g. `{ level: 5 }`) makes zip.js fall back to the WASM zlib codec — which, per
110
+ the table, does not parallelize via concurrent `add()`. Keep the default level to keep
111
+ the native-backend parallelism, or pair a custom level with Web Workers (below).
112
+
113
+ ### Parallelism is runtime-dependent
114
+
115
+ The table above is measured on **Node**, and its "no Web Workers needed" result does
116
+ **not** hold on every runtime: concurrent `add()` only spreads across cores if the
117
+ runtime runs `CompressionStream` off the main thread. Same 8 × 8 MB workload, level 6,
118
+ median of 3:
119
+
120
+ | Runtime | sequential | concurrent `add()` | concurrent `add()` + `useWebWorkers` |
121
+ |---|--:|--:|--:|
122
+ | Node.js | 2.94 s | **0.74 s** | 0.74 s |
123
+ | Bun | 1.80 s | **0.36 s** | 0.46 s |
124
+ | Deno | 1.84 s | 1.82 s | **0.47 s** |
125
+
126
+ - **Node and Bun** back `CompressionStream` with a threadpool, so concurrent `add()`
127
+ alone parallelizes — no Web Workers needed (Bun is fastest here).
128
+ - **Deno** runs `CompressionStream` on the isolate thread, so concurrent `add()` alone
129
+ gives no speedup (1.82 s ≈ its 1.84 s sequential). Set `useWebWorkers: true` and it
130
+ parallelizes properly (0.47 s), landing right beside the others.
131
+ - **Browsers vary by engine.** Safari/WebKit runs `CompressionStream` on the main thread
132
+ (serial, like Deno), so use `useWebWorkers: true` there. Chromium implements it
133
+ separately and may behave differently — check a given browser by compressing several
134
+ large buffers through `CompressionStream` sequentially versus concurrently and comparing
135
+ the wall time.
136
+
137
+ **Rule of thumb:** on Node and Bun, concurrent `add()` is enough; on Deno and
138
+ Safari/WebKit, also set `useWebWorkers: true`. Web Workers are the portable way to get
139
+ this parallelism on any runtime — and the only way once you use a non-default level
140
+ (which switches to the WASM codec).
141
+
107
142
  ## Decompression
108
143
 
109
144
  Level-6 archives, read back and fully materialized. archiver has no unzip API, so it is
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zip-js/zip-js",
3
- "version": "2.8.29",
3
+ "version": "2.8.30",
4
4
  "exports": {
5
5
  ".": "./index.js"
6
6
  },