compress-utils 0.8.0 → 0.10.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.
Files changed (167) hide show
  1. package/README.md +116 -60
  2. package/THIRD_PARTY_NOTICES.md +270 -0
  3. package/dist/algorithms/brotli/brotli.wasm +0 -0
  4. package/dist/algorithms/brotli/compress/brotli.wasm +0 -0
  5. package/dist/algorithms/brotli/compress/index.d.ts +8 -2
  6. package/dist/algorithms/brotli/compress/index.d.ts.map +1 -1
  7. package/dist/algorithms/brotli/compress/index.js +6 -0
  8. package/dist/algorithms/brotli/compress/index.js.map +1 -1
  9. package/dist/algorithms/brotli/decompress/brotli.wasm +0 -0
  10. package/dist/algorithms/brotli/decompress/index.d.ts +6 -0
  11. package/dist/algorithms/brotli/decompress/index.d.ts.map +1 -1
  12. package/dist/algorithms/brotli/decompress/index.js +6 -0
  13. package/dist/algorithms/brotli/decompress/index.js.map +1 -1
  14. package/dist/algorithms/brotli/index.d.ts +12 -2
  15. package/dist/algorithms/brotli/index.d.ts.map +1 -1
  16. package/dist/algorithms/brotli/index.js +10 -0
  17. package/dist/algorithms/brotli/index.js.map +1 -1
  18. package/dist/algorithms/bz2/bz2.wasm +0 -0
  19. package/dist/algorithms/bz2/compress/bz2.wasm +0 -0
  20. package/dist/algorithms/bz2/compress/index.d.ts +8 -2
  21. package/dist/algorithms/bz2/compress/index.d.ts.map +1 -1
  22. package/dist/algorithms/bz2/compress/index.js +6 -0
  23. package/dist/algorithms/bz2/compress/index.js.map +1 -1
  24. package/dist/algorithms/bz2/decompress/bz2.wasm +0 -0
  25. package/dist/algorithms/bz2/decompress/index.d.ts +6 -0
  26. package/dist/algorithms/bz2/decompress/index.d.ts.map +1 -1
  27. package/dist/algorithms/bz2/decompress/index.js +6 -0
  28. package/dist/algorithms/bz2/decompress/index.js.map +1 -1
  29. package/dist/algorithms/bz2/index.d.ts +12 -2
  30. package/dist/algorithms/bz2/index.d.ts.map +1 -1
  31. package/dist/algorithms/bz2/index.js +10 -0
  32. package/dist/algorithms/bz2/index.js.map +1 -1
  33. package/dist/algorithms/deflate/compress/index.d.ts +11 -0
  34. package/dist/algorithms/deflate/compress/index.d.ts.map +1 -0
  35. package/dist/algorithms/deflate/compress/index.js +18 -0
  36. package/dist/algorithms/deflate/compress/index.js.map +1 -0
  37. package/dist/algorithms/deflate/decompress/index.d.ts +12 -0
  38. package/dist/algorithms/deflate/decompress/index.d.ts.map +1 -0
  39. package/dist/algorithms/deflate/decompress/index.js +19 -0
  40. package/dist/algorithms/deflate/decompress/index.js.map +1 -0
  41. package/dist/algorithms/deflate/index.d.ts +17 -0
  42. package/dist/algorithms/deflate/index.d.ts.map +1 -0
  43. package/dist/algorithms/deflate/index.js +22 -0
  44. package/dist/algorithms/deflate/index.js.map +1 -0
  45. package/dist/algorithms/gzip/compress/gzip.wasm +0 -0
  46. package/dist/algorithms/gzip/compress/index.d.ts +8 -2
  47. package/dist/algorithms/gzip/compress/index.d.ts.map +1 -1
  48. package/dist/algorithms/gzip/compress/index.js +6 -0
  49. package/dist/algorithms/gzip/compress/index.js.map +1 -1
  50. package/dist/algorithms/gzip/decompress/gzip.wasm +0 -0
  51. package/dist/algorithms/gzip/decompress/index.d.ts +6 -0
  52. package/dist/algorithms/gzip/decompress/index.d.ts.map +1 -1
  53. package/dist/algorithms/gzip/decompress/index.js +6 -0
  54. package/dist/algorithms/gzip/decompress/index.js.map +1 -1
  55. package/dist/algorithms/gzip/gzip.wasm +0 -0
  56. package/dist/algorithms/gzip/index.d.ts +12 -2
  57. package/dist/algorithms/gzip/index.d.ts.map +1 -1
  58. package/dist/algorithms/gzip/index.js +10 -0
  59. package/dist/algorithms/gzip/index.js.map +1 -1
  60. package/dist/algorithms/lz4/compress/index.d.ts +8 -2
  61. package/dist/algorithms/lz4/compress/index.d.ts.map +1 -1
  62. package/dist/algorithms/lz4/compress/index.js +6 -0
  63. package/dist/algorithms/lz4/compress/index.js.map +1 -1
  64. package/dist/algorithms/lz4/compress/lz4.wasm +0 -0
  65. package/dist/algorithms/lz4/decompress/index.d.ts +6 -0
  66. package/dist/algorithms/lz4/decompress/index.d.ts.map +1 -1
  67. package/dist/algorithms/lz4/decompress/index.js +6 -0
  68. package/dist/algorithms/lz4/decompress/index.js.map +1 -1
  69. package/dist/algorithms/lz4/decompress/lz4.wasm +0 -0
  70. package/dist/algorithms/lz4/index.d.ts +12 -2
  71. package/dist/algorithms/lz4/index.d.ts.map +1 -1
  72. package/dist/algorithms/lz4/index.js +10 -0
  73. package/dist/algorithms/lz4/index.js.map +1 -1
  74. package/dist/algorithms/lz4/lz4.wasm +0 -0
  75. package/dist/algorithms/lz4_raw/compress/index.d.ts +7 -0
  76. package/dist/algorithms/lz4_raw/compress/index.d.ts.map +1 -0
  77. package/dist/algorithms/lz4_raw/compress/index.js +15 -0
  78. package/dist/algorithms/lz4_raw/compress/index.js.map +1 -0
  79. package/dist/algorithms/lz4_raw/decompress/index.d.ts +21 -0
  80. package/dist/algorithms/lz4_raw/decompress/index.d.ts.map +1 -0
  81. package/dist/algorithms/lz4_raw/decompress/index.js +34 -0
  82. package/dist/algorithms/lz4_raw/decompress/index.js.map +1 -0
  83. package/dist/algorithms/lz4_raw/index.d.ts +23 -0
  84. package/dist/algorithms/lz4_raw/index.d.ts.map +1 -0
  85. package/dist/algorithms/lz4_raw/index.js +34 -0
  86. package/dist/algorithms/lz4_raw/index.js.map +1 -0
  87. package/dist/algorithms/lzo/decompress/index.d.ts +21 -0
  88. package/dist/algorithms/lzo/decompress/index.d.ts.map +1 -0
  89. package/dist/algorithms/lzo/decompress/index.js +30 -0
  90. package/dist/algorithms/lzo/decompress/index.js.map +1 -0
  91. package/dist/algorithms/lzo/decompress/lzo.wasm +0 -0
  92. package/dist/algorithms/snappy/compress/index.d.ts +8 -2
  93. package/dist/algorithms/snappy/compress/index.d.ts.map +1 -1
  94. package/dist/algorithms/snappy/compress/index.js +6 -0
  95. package/dist/algorithms/snappy/compress/index.js.map +1 -1
  96. package/dist/algorithms/snappy/compress/snappy.wasm +0 -0
  97. package/dist/algorithms/snappy/decompress/index.d.ts +6 -0
  98. package/dist/algorithms/snappy/decompress/index.d.ts.map +1 -1
  99. package/dist/algorithms/snappy/decompress/index.js +6 -0
  100. package/dist/algorithms/snappy/decompress/index.js.map +1 -1
  101. package/dist/algorithms/snappy/decompress/snappy.wasm +0 -0
  102. package/dist/algorithms/snappy/index.d.ts +12 -2
  103. package/dist/algorithms/snappy/index.d.ts.map +1 -1
  104. package/dist/algorithms/snappy/index.js +10 -0
  105. package/dist/algorithms/snappy/index.js.map +1 -1
  106. package/dist/algorithms/snappy/snappy.wasm +0 -0
  107. package/dist/algorithms/xz/compress/index.d.ts +8 -2
  108. package/dist/algorithms/xz/compress/index.d.ts.map +1 -1
  109. package/dist/algorithms/xz/compress/index.js +6 -0
  110. package/dist/algorithms/xz/compress/index.js.map +1 -1
  111. package/dist/algorithms/xz/compress/xz.wasm +0 -0
  112. package/dist/algorithms/xz/decompress/index.d.ts +6 -0
  113. package/dist/algorithms/xz/decompress/index.d.ts.map +1 -1
  114. package/dist/algorithms/xz/decompress/index.js +6 -0
  115. package/dist/algorithms/xz/decompress/index.js.map +1 -1
  116. package/dist/algorithms/xz/decompress/xz.wasm +0 -0
  117. package/dist/algorithms/xz/index.d.ts +12 -2
  118. package/dist/algorithms/xz/index.d.ts.map +1 -1
  119. package/dist/algorithms/xz/index.js +10 -0
  120. package/dist/algorithms/xz/index.js.map +1 -1
  121. package/dist/algorithms/xz/xz.wasm +0 -0
  122. package/dist/algorithms/zlib/compress/index.d.ts +8 -2
  123. package/dist/algorithms/zlib/compress/index.d.ts.map +1 -1
  124. package/dist/algorithms/zlib/compress/index.js +6 -0
  125. package/dist/algorithms/zlib/compress/index.js.map +1 -1
  126. package/dist/algorithms/zlib/compress/zlib.wasm +0 -0
  127. package/dist/algorithms/zlib/decompress/index.d.ts +6 -0
  128. package/dist/algorithms/zlib/decompress/index.d.ts.map +1 -1
  129. package/dist/algorithms/zlib/decompress/index.js +6 -0
  130. package/dist/algorithms/zlib/decompress/index.js.map +1 -1
  131. package/dist/algorithms/zlib/decompress/zlib.wasm +0 -0
  132. package/dist/algorithms/zlib/index.d.ts +12 -2
  133. package/dist/algorithms/zlib/index.d.ts.map +1 -1
  134. package/dist/algorithms/zlib/index.js +10 -0
  135. package/dist/algorithms/zlib/index.js.map +1 -1
  136. package/dist/algorithms/zlib/zlib.wasm +0 -0
  137. package/dist/algorithms/zstd/compress/index.d.ts +8 -2
  138. package/dist/algorithms/zstd/compress/index.d.ts.map +1 -1
  139. package/dist/algorithms/zstd/compress/index.js +6 -0
  140. package/dist/algorithms/zstd/compress/index.js.map +1 -1
  141. package/dist/algorithms/zstd/compress/zstd.wasm +0 -0
  142. package/dist/algorithms/zstd/decompress/index.d.ts +6 -0
  143. package/dist/algorithms/zstd/decompress/index.d.ts.map +1 -1
  144. package/dist/algorithms/zstd/decompress/index.js +6 -0
  145. package/dist/algorithms/zstd/decompress/index.js.map +1 -1
  146. package/dist/algorithms/zstd/decompress/zstd.wasm +0 -0
  147. package/dist/algorithms/zstd/index.d.ts +12 -2
  148. package/dist/algorithms/zstd/index.d.ts.map +1 -1
  149. package/dist/algorithms/zstd/index.js +10 -0
  150. package/dist/algorithms/zstd/index.js.map +1 -1
  151. package/dist/algorithms/zstd/zstd.wasm +0 -0
  152. package/dist/core/capacity.d.ts +4 -0
  153. package/dist/core/capacity.d.ts.map +1 -0
  154. package/dist/core/capacity.js +11 -0
  155. package/dist/core/capacity.js.map +1 -0
  156. package/dist/core/dispatch.d.ts +25 -4
  157. package/dist/core/dispatch.d.ts.map +1 -1
  158. package/dist/core/dispatch.js +73 -6
  159. package/dist/core/dispatch.js.map +1 -1
  160. package/dist/core/loader.d.ts +1 -0
  161. package/dist/core/loader.d.ts.map +1 -1
  162. package/dist/core/loader.js.map +1 -1
  163. package/dist/core/types.d.ts +14 -2
  164. package/dist/core/types.d.ts.map +1 -1
  165. package/dist/core/types.js +3 -0
  166. package/dist/core/types.js.map +1 -1
  167. package/package.json +15 -6
package/README.md CHANGED
@@ -3,9 +3,10 @@
3
3
  [![npm version](https://img.shields.io/npm/v/compress-utils.svg)](https://www.npmjs.com/package/compress-utils)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/compress-utils.svg)](https://www.npmjs.com/package/compress-utils)
5
5
  [![types: built-in](https://img.shields.io/badge/types-built--in-blue.svg)](https://www.npmjs.com/package/compress-utils)
6
+ [![WASM build](https://img.shields.io/github/actions/workflow/status/dupontcyborg/compress-utils/build_and_test_wasm.yml?label=wasm)](https://github.com/dupontcyborg/compress-utils/actions/workflows/build_and_test_wasm.yml)
6
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
8
 
8
- Unified WebAssembly bindings for eight compression algorithms: Brotli, bzip2, LZ4, XZ/LZMA, zlib, Zstandard, Snappy, and gzip. Same API for every algorithm, in every JavaScript runtime, with tree-shakeable imports so bundlers ship only what you use.
9
+ Unified WebAssembly bindings for eight compression algorithms — Zstandard, Brotli, zlib, gzip, bzip2, LZ4, XZ/LZMA, and Snappy — over a single high-performance C core. Same API for every algorithm, in every JavaScript runtime, with tree-shakeable imports so bundlers ship only what you use.
9
10
 
10
11
  ## Installation
11
12
 
@@ -16,39 +17,38 @@ npm install compress-utils
16
17
 
17
18
  ### CDN (no bundler)
18
19
 
19
- The package is published as ESM. You can pull it straight from a CDN — no install step, no build step.
20
+ The package is published as ESM. You can pull it straight from a CDN, with no install step and no build step.
20
21
 
21
22
  ```html
22
23
  <script type="module">
23
- import { compress, decompress } from
24
- "https://esm.sh/compress-utils/zstd";
24
+ import { compress, decompress } from "https://esm.sh/compress-utils/zstd";
25
25
 
26
- const out = await compress(
27
- new TextEncoder().encode("hello")
28
- );
26
+ const out = await compress(new TextEncoder().encode("hello"));
29
27
  </script>
30
28
  ```
31
29
 
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` |
30
+ | CDN | Per-algo URL |
31
+ |----------|-------------------------------------------------------------------------------|
32
+ | esm.sh | `https://esm.sh/compress-utils/<algo>` |
33
+ | jsDelivr | `https://cdn.jsdelivr.net/npm/compress-utils/dist/algorithms/<algo>/index.js` |
34
+ | unpkg | `https://unpkg.com/compress-utils/dist/algorithms/<algo>/index.js` |
37
35
 
38
36
  ## Quick start
39
37
 
40
- Each algorithm is its own subpath import. Pick the one you need; the rest stay out of your bundle.
38
+ Each algorithm is its own subpath import. Pick the one you need, and the rest stay out of your bundle.
41
39
 
42
40
  ```ts
43
41
  import { compress, decompress } from "compress-utils/zstd";
44
42
 
45
- const input = new TextEncoder().encode("the quick brown fox " .repeat(50));
43
+ const input = new TextEncoder().encode("the quick brown fox ".repeat(50));
46
44
 
47
45
  const compressed = await compress(input, { level: 9 });
48
46
  const restored = await decompress(compressed);
49
47
  ```
50
48
 
51
- Available subpaths: `compress-utils/zstd`, `/brotli`, `/zlib`, `/bz2`, `/lz4`, `/xz`, `/snappy`, `/gzip`. Identical surface across all eight. Each also has `/<algo>/decompress` and `/<algo>/compress` variants that ship only one direction for a much smaller `.wasm` — see [Bundle size](#bundle-size).
49
+ Available subpaths: `compress-utils/zstd`, `/brotli`, `/zlib`, `/bz2`, `/lz4`, `/xz`, `/snappy`, `/gzip`, plus the raw block formats `/deflate`, `/lz4_raw` and `/lzo/decompress`. The surface is identical across all of them. Each also has `/<algo>/decompress` and `/<algo>/compress` variants that ship only one direction for a much smaller `.wasm`; see [Bundle size](#bundle-size).
50
+
51
+ ## Streaming
52
52
 
53
53
  ### Web Streams
54
54
 
@@ -72,77 +72,129 @@ chunks.push(cs.finish());
72
72
  // cs is destroyed automatically on scope exit (TS 5.2+ / Node 22+).
73
73
  ```
74
74
 
75
- If `using` isn't available in your toolchain, call `cs.destroy()` explicitly — or rely on the GC backstop (a `FinalizationRegistry` frees the C-side handle eventually).
75
+ If `using` isn't available in your toolchain, call `cs.destroy()` explicitly, or rely on the GC backstop: a `FinalizationRegistry` frees the C-side handle eventually.
76
76
 
77
77
  ## Supported algorithms
78
78
 
79
- | Algorithm | Subpath | Wire format produced |
80
- |-----------|--------------------------|--------------------------------------------|
81
- | zlib | `compress-utils/zlib` | zlib wrapper (RFC 1950) |
82
- | bzip2 | `compress-utils/bz2` | bzip2 stream |
83
- | XZ/LZMA | `compress-utils/xz` | XZ stream with CRC64 |
84
- | LZ4 | `compress-utils/lz4` | LZ4 frame (compatible with `.lz4` files) |
85
- | Zstandard | `compress-utils/zstd` | ZSTD frame with content size |
86
- | Brotli | `compress-utils/brotli` | raw Brotli stream |
87
- | Snappy | `compress-utils/snappy` | Raw Snappy block |
88
- | gzip | `compress-utils/gzip` | gzip stream (RFC 1952) |
79
+ <!-- BEGIN:algorithms -->
80
+ <!-- Generated by tools/check-readmes.py from docs/readme/manifest.json. Edit the manifest and run `tools/check-readmes.py --fix`, not this block. -->
89
81
 
90
- 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. For per-module `.wasm` sizes (and the smaller decode-only / encode-only builds), see **[Bundle size](#bundle-size)**.
82
+ | Algorithm | Subpath | Wire format |
83
+ |-----------|---------------------------------|------------------------------------------------------------------------------------------|
84
+ | Zstandard | `compress-utils/zstd` | ZSTD frame with content size |
85
+ | Brotli | `compress-utils/brotli` | Raw Brotli stream |
86
+ | zlib | `compress-utils/zlib` | zlib wrapper (RFC 1950) |
87
+ | gzip | `compress-utils/gzip` | gzip stream (RFC 1952) |
88
+ | bzip2 | `compress-utils/bz2` | bzip2 stream |
89
+ | LZ4 | `compress-utils/lz4` | LZ4 frame (interoperable with the `lz4` CLI and `.lz4` files) |
90
+ | XZ / LZMA | `compress-utils/xz` | XZ stream with CRC64 |
91
+ | Snappy | `compress-utils/snappy` | Raw Snappy block (interoperable with reference snappy and python-snappy) |
92
+ | DEFLATE | `compress-utils/deflate` | Raw DEFLATE (RFC 1951), no wrapper |
93
+ | LZ4 block | `compress-utils/lz4_raw` | Raw LZ4 block, no frame or size prefix (one-shot compression, incremental decompression) |
94
+ | LZO1X | `compress-utils/lzo/decompress` | Raw LZO1X block (decompression only) |
95
+ <!-- END:algorithms -->
91
96
 
92
- ## Bundle size
97
+ Imports are independent: `import "compress-utils/zstd"` and `import "compress-utils/brotli"` pull in two separate `.wasm` modules, not a combined bundle. Files are marked `"sideEffects": false` so unused exports are tree-shaken aggressively. For per-module `.wasm` sizes, and the smaller decode-only and encode-only builds, see [Bundle size](#bundle-size).
98
+
99
+ ### Raw blocks and output capacity
93
100
 
94
- Importing `compress-utils/<algo>` gives you the **full** codec — compress *and* decompress. If you only need one direction (a browser that just *decompresses* fetched assets is the common case), import a directional subpath and the other half is dead-stripped from the `.wasm` entirely:
101
+ Raw block formats such as those inside Parquet and ORC pages don't record their decompressed size. Pass `expectedSize`, an upper bound on the output, and the result holds only the bytes actually decoded:
95
102
 
96
103
  ```ts
97
- // decoder only, 90 KB
98
- import { decompress } from "compress-utils/zstd/decompress";
104
+ import { decompress } from "compress-utils/lz4_raw";
99
105
 
100
- // or, encoder only:
101
- import { compress } from "compress-utils/zstd/compress";
106
+ const page = await decompress(block, { expectedSize: uncompressedPageSize });
102
107
  ```
103
108
 
104
- - **`/decompress`** exposes `decompress`, `createDecompressStream`, `decompressionStream`, `setMaxDecompressedSize`, `version`.
105
- - **`/compress`** exposes `compress`, `createCompressStream`, `compressionStream`, `version`.
106
- - The default subpath keeps **both**
107
-
108
- Comparison of the gzipped sizes:
109
-
110
- | algo | full | decompress-only | compress-only |
111
- |--------|--------------:|----------------------:|----------------------:|
112
- | zstd | 128K | 36K | 106K |
113
- | brotli | 169K | 84K | 154K |
114
- | lz4 | 39K | 15K | 35K |
115
- | bz2 | 33K | 22K | 25K |
116
- | xz | 62K | 43K | 51K |
117
- | zlib | 33K | 25K | 26K |
118
- | snappy | 36K | 32K | 28K |
119
- | gzip | 80K | 52K | 60K |
120
-
121
- The `.wasm` is the bulk of what ships; the JS glue is a few KB, shared, and tree-shaken to the methods you import.
109
+ Without `expectedSize`, `lz4_raw` blocks are decoded with the incremental stream decoder, which is much slower, so pass it when you know the size. Every other algorithm accepts it too, which skips a sizing pass and decodes straight into a buffer of that size.
122
110
 
123
111
  ## Compression levels
124
112
 
125
- 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`.
113
+ Every algorithm accepts a `level` from **1 (fastest) to 10 (smallest)**. The binding maps that to each algorithm's native range internally, so you don't need to know that Zstandard goes 1–22 and zlib goes 1–9. The default is `5`.
126
114
 
127
115
  ```ts
128
116
  await compress(input, { level: 1 }); // fastest
129
117
  await compress(input, { level: 10 }); // smallest
130
118
  ```
131
119
 
120
+ ## Errors and limits
121
+
122
+ Every failure throws a `CompressError`, which carries the underlying C status code and the algorithm name:
123
+
124
+ ```ts
125
+ import { compress, decompress, CompressError } from "compress-utils/zstd";
126
+
127
+ try {
128
+ await decompress(garbage);
129
+ } catch (e) {
130
+ if (e instanceof CompressError) console.error(e.algorithm, e.code, e.message);
131
+ }
132
+ ```
133
+
134
+ `await version()` returns the library version (for example `"0.9.0"`), and `await setMaxDecompressedSize(bytes)` bounds one-shot decompression (default 1 GiB; `0` = unbounded). Both are exported from every subpath that includes decompression.
135
+
136
+ ## Preloading and synchronous calls
137
+
138
+ Each algorithm and direction-specific subpath exports `preload()`. It loads and initializes that subpath's WASM module once, and concurrent calls share initialization. A failed initialization can be retried. No codec work is performed by preload.
139
+
140
+ ```ts
141
+ import { preload, compressSync, decompressSync } from "compress-utils/zlib";
142
+ await preload();
143
+ const compressed = compressSync(new TextEncoder().encode("hello"));
144
+ const restored = decompressSync(compressed);
145
+ ```
146
+
147
+ `compressSync`, `decompressSync`, `createCompressStreamSync`, and `createDecompressStreamSync` are available for the directions exposed by the subpath. They throw with a `preload()` instruction before initialization completes. Existing asynchronous APIs initialize automatically and also enable subsequent synchronous calls. Initializing one subpath does not initialize another, because encoder and decoder subpaths use different WASM modules.
148
+
149
+ ## Concurrency
150
+
151
+ Each WASM module instance runs on the thread that loaded it, so nothing is shared between workers: every Worker initializes its own instance and keeps its own streams. Synchronous calls block the calling thread, so run expensive ones in a Worker. A stream handle holds state inside its module instance, so feed each stream from one logical flow rather than from interleaved callers.
152
+
153
+ ## Bundle size
154
+
155
+ Importing `compress-utils/<algo>` gives you the **full** codec, compress *and* decompress. If you only need one direction (a browser that just *decompresses* fetched assets is the common case), import a directional subpath and the other half is dead-stripped from the `.wasm` entirely:
156
+
157
+ ```ts
158
+ // decoder only, 36 KB gzipped for zstd
159
+ import { decompress } from "compress-utils/zstd/decompress";
160
+
161
+ // or, encoder only:
162
+ import { compress } from "compress-utils/zstd/compress";
163
+ ```
164
+
165
+ - **`/decompress`** exposes `decompress`, `createDecompressStream`, `decompressionStream`, `setMaxDecompressedSize` and `version`.
166
+ - **`/compress`** exposes `compress`, `createCompressStream`, `compressionStream` and `version`.
167
+ - The default subpath keeps **both**.
168
+
169
+ Gzipped `.wasm` sizes:
170
+
171
+ | algo | full | decompress-only | compress-only |
172
+ |--------|-----:|----------------:|--------------:|
173
+ | zstd | 128K | 36K | 106K |
174
+ | brotli | 169K | 84K | 154K |
175
+ | lz4 | 39K | 15K | 35K |
176
+ | bz2 | 33K | 22K | 25K |
177
+ | xz | 62K | 43K | 51K |
178
+ | zlib | 33K | 25K | 26K |
179
+ | snappy | 36K | 32K | 28K |
180
+ | gzip | 80K | 52K | 60K |
181
+
182
+ The `.wasm` is the bulk of what ships. The JS glue is a few KB, shared, and tree-shaken to the methods you import.
183
+
132
184
  ## Runtime support
133
185
 
134
186
  Tested in CI on every release:
135
187
 
136
- | Runtime | Status |
137
- |----------------------|--------|
138
- | Node 20, 22, 24 | ✅ |
139
- | Bun | ✅ |
140
- | Deno 2.x | ✅ |
141
- | Chromium / Firefox / WebKit (Playwright) | ✅ |
188
+ | Runtime | Status |
189
+ |------------------------------------------|--------|
190
+ | Node 20, 22, 24 | ✅ |
191
+ | Bun | ✅ |
192
+ | Deno 2.x | ✅ |
193
+ | Chromium / Firefox / WebKit (Playwright) | ✅ |
142
194
 
143
195
  ## TypeScript
144
196
 
145
- The package is TypeScript-first. `.d.ts` files ship alongside the JS for every subpath; no `@types/` package needed.
197
+ The package is TypeScript-first. `.d.ts` files ship alongside the JS for every subpath, so no `@types/` package is needed.
146
198
 
147
199
  ```ts
148
200
  import { compress, type CompressOptions, type CompressError } from "compress-utils/zstd";
@@ -151,10 +203,14 @@ const opts: CompressOptions = { level: 7 };
151
203
  const compressed: Uint8Array = await compress(input, opts);
152
204
  ```
153
205
 
206
+ ## Performance
207
+
208
+ Overhead versus native C is **0.60–0.84× on compress and 0.50–1.00× on decompress**. WASM is the slowest binding across the board: zstd and brotli decode are the worst cases because they lean on native SIMD, while lz4 decode is memory-bound and costs nothing extra in the sandbox. The reasons to choose this binding are portability, one API in every runtime, and the small per-codec bundles above, rather than beating native `node:zlib`. Compression ratio is byte-identical to every other binding. See the [language comparison](https://github.com/dupontcyborg/compress-utils/blob/main/benchmarks/README.md#language-comparison) for methodology and the full chart.
209
+
154
210
  ## License
155
211
 
156
212
  MIT. See [LICENSE](https://github.com/dupontcyborg/compress-utils/blob/main/LICENSE).
157
213
 
158
214
  ---
159
215
 
160
- Built by [Nico Dupont](https://nico.codes).
216
+ Part of [compress-utils](https://github.com/dupontcyborg/compress-utils). Built by [Nico Dupont](https://nico.codes).
@@ -0,0 +1,270 @@
1
+ # Third-party notices
2
+
3
+ compress-utils is MIT-licensed (see `LICENSE`). It also contains code from the projects below, each under its own license, and their license texts are reproduced here as those licenses require. The Python wheel, npm package, Rust crate and Go module all ship this file; a build that includes only some codecs contains only those codecs' code.
4
+
5
+ Pinned versions are recorded in `third_party/manifest.json` and `third_party/VENDOR.md`.
6
+
7
+ ## Zstandard (zstd)
8
+
9
+ - **Source**: https://github.com/facebook/zstd at `v1.5.7` (`third_party/zstd/`)
10
+ - **License**: BSD-3-Clause
11
+ - **Note**: zstd is dual-licensed; compress-utils uses it under the BSD license.
12
+
13
+ ```text
14
+ BSD License
15
+
16
+ For Zstandard software
17
+
18
+ Copyright (c) Meta Platforms, Inc. and affiliates. All rights reserved.
19
+
20
+ Redistribution and use in source and binary forms, with or without modification,
21
+ are permitted provided that the following conditions are met:
22
+
23
+ * Redistributions of source code must retain the above copyright notice, this
24
+ list of conditions and the following disclaimer.
25
+
26
+ * Redistributions in binary form must reproduce the above copyright notice,
27
+ this list of conditions and the following disclaimer in the documentation
28
+ and/or other materials provided with the distribution.
29
+
30
+ * Neither the name Facebook, nor Meta, nor the names of its contributors may
31
+ be used to endorse or promote products derived from this software without
32
+ specific prior written permission.
33
+
34
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
35
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
38
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
41
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44
+ ```
45
+
46
+ ## Brotli
47
+
48
+ - **Source**: https://github.com/google/brotli at `v1.2.0` (`third_party/brotli/`)
49
+ - **License**: MIT
50
+
51
+ ```text
52
+ Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors.
53
+
54
+ Permission is hereby granted, free of charge, to any person obtaining a copy
55
+ of this software and associated documentation files (the "Software"), to deal
56
+ in the Software without restriction, including without limitation the rights
57
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
58
+ copies of the Software, and to permit persons to whom the Software is
59
+ furnished to do so, subject to the following conditions:
60
+
61
+ The above copyright notice and this permission notice shall be included in
62
+ all copies or substantial portions of the Software.
63
+
64
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
66
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
67
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
68
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
69
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
70
+ THE SOFTWARE.
71
+ ```
72
+
73
+ ## zlib
74
+
75
+ - **Source**: https://github.com/madler/zlib at `v1.3.2` (`third_party/zlib/`)
76
+ - **License**: Zlib
77
+
78
+ ```text
79
+ Copyright notice:
80
+
81
+ (C) 1995-2026 Jean-loup Gailly and Mark Adler
82
+
83
+ This software is provided 'as-is', without any express or implied
84
+ warranty. In no event will the authors be held liable for any damages
85
+ arising from the use of this software.
86
+
87
+ Permission is granted to anyone to use this software for any purpose,
88
+ including commercial applications, and to alter it and redistribute it
89
+ freely, subject to the following restrictions:
90
+
91
+ 1. The origin of this software must not be misrepresented; you must not
92
+ claim that you wrote the original software. If you use this software
93
+ in a product, an acknowledgment in the product documentation would be
94
+ appreciated but is not required.
95
+ 2. Altered source versions must be plainly marked as such, and must not be
96
+ misrepresented as being the original software.
97
+ 3. This notice may not be removed or altered from any source distribution.
98
+
99
+ Jean-loup Gailly Mark Adler
100
+ jloup@gzip.org madler@alumni.caltech.edu
101
+ ```
102
+
103
+ ## bzip2
104
+
105
+ - **Source**: https://gitlab.com/bzip2/bzip2 at `bzip2-1.0.8` (`third_party/bz2/`)
106
+ - **License**: bzip2-1.0.6
107
+
108
+ ```text
109
+ --------------------------------------------------------------------------
110
+
111
+ This program, "bzip2", the associated library "libbzip2", and all
112
+ documentation, are copyright (C) 1996-2019 Julian R Seward. All
113
+ rights reserved.
114
+
115
+ Redistribution and use in source and binary forms, with or without
116
+ modification, are permitted provided that the following conditions
117
+ are met:
118
+
119
+ 1. Redistributions of source code must retain the above copyright
120
+ notice, this list of conditions and the following disclaimer.
121
+
122
+ 2. The origin of this software must not be misrepresented; you must
123
+ not claim that you wrote the original software. If you use this
124
+ software in a product, an acknowledgment in the product
125
+ documentation would be appreciated but is not required.
126
+
127
+ 3. Altered source versions must be plainly marked as such, and must
128
+ not be misrepresented as being the original software.
129
+
130
+ 4. The name of the author may not be used to endorse or promote
131
+ products derived from this software without specific prior written
132
+ permission.
133
+
134
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
135
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
136
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
137
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
138
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
139
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
140
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
141
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
142
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
143
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
144
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145
+
146
+ Julian Seward, jseward@acm.org
147
+ bzip2/libbzip2 version 1.0.8 of 13 July 2019
148
+
149
+ --------------------------------------------------------------------------
150
+ ```
151
+
152
+ ## LZ4
153
+
154
+ - **Source**: https://github.com/lz4/lz4 at `v1.10.0` (`third_party/lz4/`)
155
+ - **License**: BSD-2-Clause
156
+ - **Note**: Only the LZ4 library (`lib/`) is included; this is its license.
157
+
158
+ ```text
159
+ LZ4 Library
160
+ Copyright (c) 2011-2020, Yann Collet
161
+ All rights reserved.
162
+
163
+ Redistribution and use in source and binary forms, with or without modification,
164
+ are permitted provided that the following conditions are met:
165
+
166
+ * Redistributions of source code must retain the above copyright notice, this
167
+ list of conditions and the following disclaimer.
168
+
169
+ * Redistributions in binary form must reproduce the above copyright notice, this
170
+ list of conditions and the following disclaimer in the documentation and/or
171
+ other materials provided with the distribution.
172
+
173
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
174
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
175
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
176
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
177
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
178
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
179
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
180
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
181
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
182
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
183
+ ```
184
+
185
+ ## XZ Utils (liblzma)
186
+
187
+ - **Source**: https://github.com/tukaani-project/xz at `v5.8.3` (`third_party/xz/`)
188
+ - **License**: 0BSD
189
+ - **Note**: Only liblzma is included; it is under the BSD Zero Clause License.
190
+
191
+ ```text
192
+ Permission to use, copy, modify, and/or distribute this
193
+ software for any purpose with or without fee is hereby granted.
194
+
195
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
196
+ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
197
+ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
198
+ THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
199
+ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
200
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
201
+ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
202
+ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
203
+ ```
204
+
205
+ ## snappy-c
206
+
207
+ - **Source**: https://github.com/andikleen/snappy-c at `fef67ac6effb40c83fb5e37eaf243381fa056f9b` (`third_party/snappy/`)
208
+ - **License**: BSD-3-Clause
209
+
210
+ ```text
211
+ The snappy-c code is under the same license as the original snappy source
212
+
213
+ Copyright 2011 Intel Corporation All Rights Reserved.
214
+
215
+ Redistribution and use in source and binary forms, with or without
216
+ modification, are permitted provided that the following conditions are
217
+ met:
218
+
219
+ * Redistributions of source code must retain the above copyright
220
+ notice, this list of conditions and the following disclaimer.
221
+ * Redistributions in binary form must reproduce the above
222
+ copyright notice, this list of conditions and the following disclaimer
223
+ in the documentation and/or other materials provided with the
224
+ distribution.
225
+ * Neither the name of Intel Corporation nor the names of its
226
+ contributors may be used to endorse or promote products derived from
227
+ this software without specific prior written permission.
228
+
229
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
230
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
231
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
232
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
233
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
234
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
235
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
237
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
238
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
239
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
240
+ ```
241
+
242
+ ## lzokay
243
+
244
+ - **Source**: https://github.com/AxioDL/lzokay at `db2df1fcbebc2ed06c10f727f72567d40f06a2be` (`third_party/lzokay/`)
245
+ - **License**: MIT
246
+ - **Note**: Decoder-only C adaptation; see `third_party/lzokay/PROVENANCE.md`.
247
+
248
+ ```text
249
+ The MIT License
250
+
251
+ Copyright (c) 2018 Jack Andersen
252
+
253
+ Permission is hereby granted, free of charge, to any person obtaining a copy
254
+ of this software and associated documentation files (the "Software"), to deal
255
+ in the Software without restriction, including without limitation the rights
256
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
257
+ copies of the Software, and to permit persons to whom the Software is
258
+ furnished to do so, subject to the following conditions:
259
+
260
+ The above copyright notice and this permission notice shall be included in all
261
+ copies or substantial portions of the Software.
262
+
263
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
264
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
265
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
266
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
267
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
268
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
269
+ SOFTWARE.
270
+ ```
Binary file
@@ -1,8 +1,14 @@
1
1
  export declare const compress: (input: Uint8Array, opts?: import("./index.js").CompressOptions) => Promise<Uint8Array>;
2
+ /** Synchronous counterpart; requires completed preload(). */
3
+ export declare const compressSync: (input: Uint8Array, opts?: import("./index.js").CompressOptions) => Uint8Array;
2
4
  export declare const createCompressStream: (opts?: import("./index.js").CompressOptions) => Promise<import("./index.js").CompressStream>;
3
- export declare const compressionStream: (opts?: import("./index.js").CompressOptions) => TransformStream<Uint8Array, Uint8Array>;
5
+ /** Synchronous counterpart; requires completed preload(). */
6
+ export declare const createCompressStreamSync: (opts?: import("./index.js").CompressOptions) => import("./index.js").CompressStream;
7
+ export declare const compressionStream: (opts?: import("./index.js").CompressionStreamOptions) => TransformStream<Uint8Array, Uint8Array>;
8
+ /** Initializes this independently loaded WASM subpath. */
9
+ export declare const preload: () => Promise<void>;
4
10
  export declare const version: () => Promise<string>;
5
11
  export { CompressError } from "../../../core/types.js";
6
- export type { CompressOptions, AlgorithmName } from "../../../core/types.js";
12
+ export type { CompressOptions, CompressionStreamOptions, AlgorithmName, } from "../../../core/types.js";
7
13
  export type { CompressStream } from "../../../core/dispatch.js";
8
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/brotli/compress/index.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,QAAQ,yFAAoB,CAAC;AAC1C,eAAO,MAAM,oBAAoB,+FAAgC,CAAC;AAClE,eAAO,MAAM,iBAAiB,0FAA6B,CAAC;AAC5D,eAAO,MAAM,OAAO,uBAAmB,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC7E,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/brotli/compress/index.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,QAAQ,yFAAoB,CAAC;AAC1C,6DAA6D;AAC7D,eAAO,MAAM,YAAY,gFAAwB,CAAC;AAClD,eAAO,MAAM,oBAAoB,+FAAgC,CAAC;AAClE,6DAA6D;AAC7D,eAAO,MAAM,wBAAwB,sFAAoC,CAAC;AAC1E,eAAO,MAAM,iBAAiB,mGAA6B,CAAC;AAC5D,0DAA0D;AAC1D,eAAO,MAAM,OAAO,qBAAmB,CAAC;AACxC,eAAO,MAAM,OAAO,uBAAmB,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EACR,eAAe,EACf,wBAAwB,EACxB,aAAa,GAChB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC"}
@@ -8,8 +8,14 @@ import { defineAlgorithm } from "../../../core/algorithm.js";
8
8
  import { Algorithm } from "../../../core/types.js";
9
9
  const bindings = /*#__PURE__*/ defineAlgorithm(Algorithm.Brotli, "brotli", new URL("./brotli.wasm", import.meta.url));
10
10
  export const compress = bindings.compress;
11
+ /** Synchronous counterpart; requires completed preload(). */
12
+ export const compressSync = bindings.compressSync;
11
13
  export const createCompressStream = bindings.createCompressStream;
14
+ /** Synchronous counterpart; requires completed preload(). */
15
+ export const createCompressStreamSync = bindings.createCompressStreamSync;
12
16
  export const compressionStream = bindings.compressionStream;
17
+ /** Initializes this independently loaded WASM subpath. */
18
+ export const preload = bindings.preload;
13
19
  export const version = bindings.version;
14
20
  export { CompressError } from "../../../core/types.js";
15
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/algorithms/brotli/compress/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,MAAM,QAAQ,GAAG,aAAa,CAAC,eAAe,CAC1C,SAAS,CAAC,MAAM,EAChB,QAAQ,EACR,IAAI,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAC5C,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;AAC1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,oBAAoB,CAAC;AAClE,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAC;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/algorithms/brotli/compress/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,MAAM,QAAQ,GAAG,aAAa,CAAC,eAAe,CAC1C,SAAS,CAAC,MAAM,EAChB,QAAQ,EACR,IAAI,GAAG,CAAC,eAAe,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAC5C,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;AAC1C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;AAClD,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,oBAAoB,CAAC;AAClE,6DAA6D;AAC7D,MAAM,CAAC,MAAM,wBAAwB,GAAG,QAAQ,CAAC,wBAAwB,CAAC;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,iBAAiB,CAAC;AAC5D,0DAA0D;AAC1D,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,6 +1,12 @@
1
1
  export declare const decompress: (input: Uint8Array, opts?: import("./index.js").DecompressOptions) => Promise<Uint8Array>;
2
+ /** Synchronous counterpart; requires completed preload(). */
3
+ export declare const decompressSync: (input: Uint8Array, opts?: import("./index.js").DecompressOptions) => Uint8Array;
2
4
  export declare const createDecompressStream: () => Promise<import("./index.js").DecompressStream>;
5
+ /** Synchronous counterpart; requires completed preload(). */
6
+ export declare const createDecompressStreamSync: () => import("./index.js").DecompressStream;
3
7
  export declare const decompressionStream: () => TransformStream<Uint8Array, Uint8Array>;
8
+ /** Initializes this independently loaded WASM subpath. */
9
+ export declare const preload: () => Promise<void>;
4
10
  export declare const version: () => Promise<string>;
5
11
  export declare const setMaxDecompressedSize: (bytes: number) => Promise<void>;
6
12
  export { CompressError } from "../../../core/types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/brotli/decompress/index.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,UAAU,2FAAsB,CAAC;AAC9C,eAAO,MAAM,sBAAsB,sDAAkC,CAAC;AACtE,eAAO,MAAM,mBAAmB,+CAA+B,CAAC;AAChE,eAAO,MAAM,OAAO,uBAAmB,CAAC;AACxC,eAAO,MAAM,sBAAsB,kCAAkC,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/algorithms/brotli/decompress/index.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,UAAU,2FAAsB,CAAC;AAC9C,6DAA6D;AAC7D,eAAO,MAAM,cAAc,kFAA0B,CAAC;AACtD,eAAO,MAAM,sBAAsB,sDAAkC,CAAC;AACtE,6DAA6D;AAC7D,eAAO,MAAM,0BAA0B,6CAAsC,CAAC;AAC9E,eAAO,MAAM,mBAAmB,+CAA+B,CAAC;AAChE,0DAA0D;AAC1D,eAAO,MAAM,OAAO,qBAAmB,CAAC;AACxC,eAAO,MAAM,OAAO,uBAAmB,CAAC;AACxC,eAAO,MAAM,sBAAsB,kCAAkC,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -8,8 +8,14 @@ import { defineAlgorithm } from "../../../core/algorithm.js";
8
8
  import { Algorithm } from "../../../core/types.js";
9
9
  const bindings = /*#__PURE__*/ defineAlgorithm(Algorithm.Brotli, "brotli", new URL("./brotli.wasm", import.meta.url));
10
10
  export const decompress = bindings.decompress;
11
+ /** Synchronous counterpart; requires completed preload(). */
12
+ export const decompressSync = bindings.decompressSync;
11
13
  export const createDecompressStream = bindings.createDecompressStream;
14
+ /** Synchronous counterpart; requires completed preload(). */
15
+ export const createDecompressStreamSync = bindings.createDecompressStreamSync;
12
16
  export const decompressionStream = bindings.decompressionStream;
17
+ /** Initializes this independently loaded WASM subpath. */
18
+ export const preload = bindings.preload;
13
19
  export const version = bindings.version;
14
20
  export const setMaxDecompressedSize = bindings.setMaxDecompressedSize;
15
21
  export { CompressError } from "../../../core/types.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/algorithms/brotli/decompress/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,MAAM,QAAQ,GAAG,aAAa,CAAC,eAAe,CAC1C,SAAS,CAAC,MAAM,EAChB,QAAQ,EACR,IAAI,GAAG,CAAC,eAAe,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAC5C,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;AAC9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;AACtE,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC;AAChE,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AACxC,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/algorithms/brotli/decompress/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,MAAM,QAAQ,GAAG,aAAa,CAAC,eAAe,CAC1C,SAAS,CAAC,MAAM,EAChB,QAAQ,EACR,IAAI,GAAG,CAAC,eAAe,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAC5C,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;AAC9C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;AACtE,6DAA6D;AAC7D,MAAM,CAAC,MAAM,0BAA0B,GAAG,QAAQ,CAAC,0BAA0B,CAAC;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC;AAChE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AACxC,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC"}