@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 +35 -0
- package/deno.json +1 -1
- package/dist/zip-core.js +527 -48
- package/dist/zip-core.min.js +1 -1
- package/dist/zip-fs-core.js +413 -48
- package/dist/zip-fs-core.min.js +1 -1
- package/dist/zip-fs-native.js +589 -52
- package/dist/zip-fs-native.min.js +1 -1
- package/dist/zip-fs.js +587 -50
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-legacy.js +528 -49
- package/dist/zip-legacy.min.js +1 -1
- package/dist/zip-module.wasm +0 -0
- package/dist/zip-native.js +531 -52
- package/dist/zip-native.min.js +1 -1
- package/dist/zip-web-worker-native.js +1 -1
- package/dist/zip-web-worker.js +1 -1
- package/dist/zip.js +529 -50
- package/dist/zip.min.js +1 -1
- package/index-native.cjs +589 -52
- package/index-native.min.js +1 -1
- package/index.cjs +587 -50
- package/index.d.ts +126 -1
- package/index.min.js +1 -1
- package/lib/core/options.js +11 -1
- package/lib/core/streams/codecs/crc32.js +39 -11
- package/lib/core/streams/zip-entry-stream.js +85 -5
- package/lib/core/streams/zlib-js/zlib-streams.min.js +1 -1
- package/lib/core/streams/zlib-wasm/zlib-streams.wasm +0 -0
- package/lib/core/util/opfs-temp-stream.js +175 -0
- package/lib/core/web-worker-inline-native.js +1 -1
- package/lib/core/web-worker-inline-wasm.js +1 -1
- package/lib/core/zip-fs.js +58 -0
- package/lib/core/zip-reader.js +219 -31
- package/lib/core/zip-writer.js +11 -0
- package/lib/core/zlib-streams-inline.js +1 -1
- package/lib/zip-core-base.js +4 -1
- package/package.json +1 -1
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
|