compress-utils 0.7.0 → 0.7.1
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/README.md +24 -30
- package/dist/algorithms/brotli/brotli.wasm +0 -0
- package/dist/algorithms/bz2/bz2.wasm +0 -0
- package/dist/algorithms/lz4/lz4.wasm +0 -0
- package/dist/algorithms/xz/xz.wasm +0 -0
- package/dist/algorithms/zlib/zlib.wasm +0 -0
- package/dist/algorithms/zstd/zstd.wasm +0 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,6 +16,25 @@ npm install compress-utils
|
|
|
16
16
|
|
|
17
17
|
No native dependencies, no `postinstall` scripts. Pure WebAssembly. TypeScript types are bundled.
|
|
18
18
|
|
|
19
|
+
### CDN (no bundler)
|
|
20
|
+
|
|
21
|
+
The package is published as ESM. You can pull it straight from a CDN — no install step, no build step.
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<script type="module">
|
|
25
|
+
import { compress, decompress } from "https://esm.sh/compress-utils/zstd";
|
|
26
|
+
const out = await compress(new TextEncoder().encode("hello"));
|
|
27
|
+
</script>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Alternate CDN endpoints:
|
|
31
|
+
|
|
32
|
+
| CDN | Per-algo URL |
|
|
33
|
+
|------------|-----------------------------------------------------------------------|
|
|
34
|
+
| esm.sh | `https://esm.sh/compress-utils/<algo>` |
|
|
35
|
+
| jsDelivr | `https://cdn.jsdelivr.net/npm/compress-utils/dist/algorithms/<algo>/index.js` |
|
|
36
|
+
| unpkg | `https://unpkg.com/compress-utils/dist/algorithms/<algo>/index.js` |
|
|
37
|
+
|
|
19
38
|
## Quick start
|
|
20
39
|
|
|
21
40
|
Each algorithm is its own subpath import. Pick the one you need; the rest stay out of your bundle.
|
|
@@ -68,28 +87,6 @@ If `using` isn't available in your toolchain, call `cs.destroy()` explicitly —
|
|
|
68
87
|
|
|
69
88
|
Imports are independent — `import "compress-utils/zstd"` and `import "compress-utils/brotli"` pull in two separate `.wasm` modules, not a combined bundle. Files marked `"sideEffects": false` so unused exports are tree-shaken aggressively.
|
|
70
89
|
|
|
71
|
-
## Other helpful APIs
|
|
72
|
-
|
|
73
|
-
```ts
|
|
74
|
-
import {
|
|
75
|
-
version,
|
|
76
|
-
setMaxDecompressedSize,
|
|
77
|
-
CompressError,
|
|
78
|
-
} from "compress-utils/zstd";
|
|
79
|
-
|
|
80
|
-
await version(); // "0.1.0"
|
|
81
|
-
await setMaxDecompressedSize(256 * 1024 ** 2);
|
|
82
|
-
// bound one-shot decompression (default: 1 GiB; 0 = unbounded)
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
await decompress(garbage);
|
|
86
|
-
} catch (e) {
|
|
87
|
-
if (e instanceof CompressError) {
|
|
88
|
-
console.log(e.algorithm, e.code, e.message);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
90
|
## Compression levels
|
|
94
91
|
|
|
95
92
|
Every algorithm accepts a `level` from **1 (fastest) to 10 (smallest)**. The binding maps that to each algorithm's native range internally — you don't need to know that Zstandard goes 1–22 or zlib goes 1–9. Defaults to `5`.
|
|
@@ -105,18 +102,11 @@ Tested in CI on every release:
|
|
|
105
102
|
|
|
106
103
|
| Runtime | Status |
|
|
107
104
|
|----------------------|--------|
|
|
108
|
-
| Node 20, 22
|
|
105
|
+
| Node 20, 22, 24 | ✅ |
|
|
109
106
|
| Bun | ✅ |
|
|
110
107
|
| Deno 2.x | ✅ |
|
|
111
108
|
| Chromium / Firefox / WebKit (Playwright) | ✅ |
|
|
112
109
|
|
|
113
|
-
The package exposes the [`browser`](https://nodejs.org/api/packages.html#community-conditions-definitions), `node`, `deno`, and `bun` export conditions:
|
|
114
|
-
|
|
115
|
-
- Browser, Deno, and Bun consumers get a `fetch`-based loader → `WebAssembly.instantiateStreaming` (concurrent download + compile).
|
|
116
|
-
- Node consumers get a `fs.readFile`-based loader (Node's built-in `fetch` doesn't handle `file://`).
|
|
117
|
-
|
|
118
|
-
You don't need to configure anything — the right entry is picked automatically. The browser entry has zero references to `node:*` modules, so it bundles cleanly under Vite, esbuild, webpack 5, Rollup, etc.
|
|
119
|
-
|
|
120
110
|
## TypeScript
|
|
121
111
|
|
|
122
112
|
The package is TypeScript-first. `.d.ts` files ship alongside the JS for every subpath; no `@types/` package needed.
|
|
@@ -142,3 +132,7 @@ Per-algorithm imports + `sideEffects: false` mean modern bundlers tree-shake agg
|
|
|
142
132
|
## License
|
|
143
133
|
|
|
144
134
|
MIT. See [LICENSE](https://github.com/dupontcyborg/compress-utils/blob/main/LICENSE).
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
Built by [Nico Dupont](https://nico.codes).
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compress-utils",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"description": "WASM compression bindings for zstd, brotli, zlib, bz2, lz4, xz
|
|
3
|
+
"version": "0.7.1",
|
|
4
|
+
"description": "WASM compression bindings for zstd, brotli, zlib, bz2, lz4, xz - all tree-shakeable.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"repository": {
|