node-liblzma 2.0.0 → 2.1.0

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 (67) hide show
  1. package/README.md +156 -63
  2. package/binding.gyp +7 -2
  3. package/index.d.ts +26 -3
  4. package/lib/errors.d.ts.map +1 -1
  5. package/lib/errors.js +26 -15
  6. package/lib/errors.js.map +1 -1
  7. package/lib/lzma.d.ts +236 -2
  8. package/lib/lzma.d.ts.map +1 -1
  9. package/lib/lzma.js +225 -39
  10. package/lib/lzma.js.map +1 -1
  11. package/lib/pool.d.ts.map +1 -1
  12. package/lib/pool.js +9 -3
  13. package/lib/pool.js.map +1 -1
  14. package/lib/types.d.ts +68 -1
  15. package/lib/types.d.ts.map +1 -1
  16. package/package.json +34 -17
  17. package/scripts/build_xz_with_cmake.py +23 -26
  18. package/scripts/download_xz_from_github.py +14 -13
  19. package/src/bindings/node-liblzma.cpp +40 -4
  20. package/src/bindings/node-liblzma.hpp +2 -1
  21. package/xz-version.json +3 -3
  22. package/.claude/settings.local.json +0 -92
  23. package/.gitattributes +0 -3
  24. package/.release-it.json +0 -6
  25. package/CHANGELOG.md +0 -209
  26. package/History.md +0 -79
  27. package/RELEASING.md +0 -131
  28. package/biome.json +0 -81
  29. package/coverage/base.css +0 -224
  30. package/coverage/block-navigation.js +0 -87
  31. package/coverage/errors.ts.html +0 -586
  32. package/coverage/favicon.png +0 -0
  33. package/coverage/index.html +0 -146
  34. package/coverage/lcov-report/base.css +0 -224
  35. package/coverage/lcov-report/block-navigation.js +0 -87
  36. package/coverage/lcov-report/errors.ts.html +0 -586
  37. package/coverage/lcov-report/favicon.png +0 -0
  38. package/coverage/lcov-report/index.html +0 -146
  39. package/coverage/lcov-report/lzma.ts.html +0 -2596
  40. package/coverage/lcov-report/pool.ts.html +0 -769
  41. package/coverage/lcov-report/prettify.css +0 -1
  42. package/coverage/lcov-report/prettify.js +0 -2
  43. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  44. package/coverage/lcov-report/sorter.js +0 -210
  45. package/coverage/lcov.info +0 -636
  46. package/coverage/lzma.ts.html +0 -2596
  47. package/coverage/pool.ts.html +0 -769
  48. package/coverage/prettify.css +0 -1
  49. package/coverage/prettify.js +0 -2
  50. package/coverage/sort-arrow-sprite.png +0 -0
  51. package/coverage/sorter.js +0 -210
  52. package/coverage-reports/assets/monocart-coverage-app.js +0 -2
  53. package/coverage-reports/coverage-data.js +0 -1
  54. package/coverage-reports/index.html +0 -48
  55. package/err.log +0 -26
  56. package/pnpm-workspace.yaml +0 -3
  57. package/scripts/analyze-coverage.js +0 -132
  58. package/scripts/compare-coverage-tools.js +0 -93
  59. package/scripts/prebuildify.py +0 -13
  60. package/src/errors.ts +0 -167
  61. package/src/lzma.ts +0 -839
  62. package/src/pool.ts +0 -228
  63. package/src/types.ts +0 -30
  64. package/tsconfig.json +0 -50
  65. package/vitest.config.istanbul.ts +0 -29
  66. package/vitest.config.monocart.ts +0 -44
  67. package/vitest.config.ts +0 -44
package/README.md CHANGED
@@ -4,7 +4,7 @@ Node-liblzma
4
4
  [![NPM Version](https://img.shields.io/npm/v/node-liblzma.svg)](https://npmjs.org/package/node-liblzma)
5
5
  [![NPM Downloads](https://img.shields.io/npm/dm/node-liblzma.svg)](https://npmjs.org/package/node-liblzma)
6
6
  [![CI Status](https://github.com/oorabona/node-liblzma/actions/workflows/ci-unified.yml/badge.svg)](https://github.com/oorabona/node-liblzma/actions/workflows/ci-unified.yml)
7
- [![Code Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](#testing)
7
+ [![Documentation](https://img.shields.io/badge/docs-TypeDoc-blue.svg)](https://oorabona.github.io/node-liblzma/)
8
8
 
9
9
  # What is liblzma/XZ ?
10
10
 
@@ -30,8 +30,81 @@ See [installation](#installation) below.
30
30
  > Only LZMA2 is supported for compression output.
31
31
  But the library can open and read any LZMA1 or LZMA2 compressed file.
32
32
 
33
+ # Quick Start
34
+
35
+ ```bash
36
+ npm install node-liblzma
37
+ ```
38
+
39
+ ```typescript
40
+ import { xzAsync, unxzAsync, createXz, createUnxz } from 'node-liblzma';
41
+
42
+ // Simple: Compress a buffer
43
+ const compressed = await xzAsync(Buffer.from('Hello, World!'));
44
+ const decompressed = await unxzAsync(compressed);
45
+
46
+ // Streaming: Compress a file
47
+ import { createReadStream, createWriteStream } from 'fs';
48
+
49
+ createReadStream('input.txt')
50
+ .pipe(createXz())
51
+ .pipe(createWriteStream('output.xz'));
52
+
53
+ // With progress monitoring
54
+ const compressor = createXz();
55
+ compressor.on('progress', ({ bytesRead, bytesWritten }) => {
56
+ console.log(`${bytesRead} bytes in → ${bytesWritten} bytes out`);
57
+ });
58
+ ```
59
+
60
+ **Promise style (with `.then()`):**
61
+
62
+ ```typescript
63
+ import { xzAsync, unxzAsync } from 'node-liblzma';
64
+
65
+ xzAsync(Buffer.from('Hello, World!'))
66
+ .then(compressed => {
67
+ console.log('Compressed size:', compressed.length);
68
+ return unxzAsync(compressed);
69
+ })
70
+ .then(decompressed => {
71
+ console.log('Decompressed:', decompressed.toString());
72
+ })
73
+ .catch(err => {
74
+ console.error('Compression failed:', err);
75
+ });
76
+ ```
77
+
78
+ **Callback style (Node.js traditional):**
79
+
80
+ ```typescript
81
+ import { xz, unxz } from 'node-liblzma';
82
+
83
+ xz(Buffer.from('Hello, World!'), (err, compressed) => {
84
+ if (err) throw err;
85
+ unxz(compressed, (err, decompressed) => {
86
+ if (err) throw err;
87
+ console.log('Decompressed:', decompressed.toString());
88
+ });
89
+ });
90
+ ```
91
+
92
+ 📖 **Full API documentation**: [oorabona.github.io/node-liblzma](https://oorabona.github.io/node-liblzma/)
93
+
33
94
  # What's new ?
34
95
 
96
+ ## Latest Updates (2026)
97
+
98
+ * **Progress Events**: Monitor compression/decompression progress with real-time events
99
+ ```typescript
100
+ const compressor = createXz();
101
+ compressor.on('progress', ({ bytesRead, bytesWritten }) => {
102
+ console.log(`Read: ${bytesRead}, Written: ${bytesWritten}`);
103
+ });
104
+ ```
105
+ * **API Documentation**: Full TypeDoc documentation with Material theme at [oorabona.github.io/node-liblzma](https://oorabona.github.io/node-liblzma/)
106
+ * **XZ Utils 5.8.2**: Updated to latest stable version
107
+
35
108
  ## Version 2.0 (2025) - Complete Modernization
36
109
 
37
110
  This major release brings the library into 2025 with modern tooling and TypeScript support:
@@ -39,7 +112,7 @@ This major release brings the library into 2025 with modern tooling and TypeScri
39
112
  * **Full TypeScript migration**: Complete rewrite from CoffeeScript to TypeScript for better type safety and developer experience
40
113
  * **Promise-based APIs**: New async functions `xzAsync()` and `unxzAsync()` with Promise support
41
114
  * **Modern testing**: Migrated from Mocha to Vitest with improved performance and better TypeScript integration
42
- * **Enhanced tooling**:
115
+ * **Enhanced tooling**:
43
116
  - [Biome](https://biomejs.dev/) for fast linting and formatting
44
117
  - Pre-commit hooks with nano-staged and simple-git-hooks
45
118
  - pnpm as package manager for better dependency management
@@ -75,11 +148,11 @@ Several prebuilt versions are bundled within the package.
75
148
 
76
149
  If your OS/architecture matches, you will use this version which has been compiled using the following default flags:
77
150
 
78
- Flag | Description | Default value | Possible values
79
- -----|-------------|---------------|----------------
80
- USE_GLOBAL | Should the library use the system provided DLL/.so library ? | `yes` (`no` if OS is Windows) | `yes` or `no`
81
- RUNTIME_LINK | Should the library be linked statically or use the shared LZMA library ? | `shared` | `static` or `shared`
82
- ENABLE_THREAD_SUPPORT | Does the LZMA library support threads ? | `yes` | `yes` or `no`
151
+ | Flag | Description | Default | Values |
152
+ |------|-------------|---------|--------|
153
+ | `USE_GLOBAL` | Use system liblzma library | `yes` (`no` on Windows) | `yes`, `no` |
154
+ | `RUNTIME_LINK` | Static or shared linking | `shared` | `static`, `shared` |
155
+ | `ENABLE_THREAD_SUPPORT` | Enable thread support | `yes` | `yes`, `no` |
83
156
 
84
157
  If not `node-gyp` will automagically start compiling stuff according to the environment variables set, or the default values above.
85
158
 
@@ -107,44 +180,33 @@ var lzma = require('node-liblzma');
107
180
  import * as lzma from 'node-liblzma';
108
181
  ```
109
182
 
110
- Zlib | XZlib | Arguments
111
- ----------------|-------------------------|---------------
112
- createGzip | createXz | ([lzma_options, [options]])
113
- createGunzip | createUnxz | ([lzma_options, [options]])
114
- gzip | xz | (buf, [options], callback)
115
- gunzip | unxz | (buf, [options], callback)
116
- gzipSync | xzSync | (buf, [options])
117
- gunzipSync | unxzSync | (buf, [options])
118
- - | xzAsync | (buf, [options]) Promise\<Buffer>
119
- - | unxzAsync | (buf, [options]) Promise\<Buffer>
120
-
121
- ## Constants
122
-
123
- `options` is an `Object` with the following possible attributes:
124
-
125
- Attribute | Type | Available options
126
- ---------------------|----------|------------
127
- check | Uint32 | NONE
128
- | |CRC32
129
- | |CRC64
130
- | |SHA256
131
- preset | Uint32 | DEFAULT
132
- | |EXTREME
133
- flag | Uint32 | TELL_NO_CHECK
134
- | |TELL_UNSUPPORTED_CHECK
135
- | |TELL_ANY_CHECK
136
- | |CONCATENATED
137
- mode | Uint32 | FAST
138
- | |NORMAL
139
- filters | Array | LZMA2 (added by default)
140
- | |X86
141
- | |POWERPC
142
- | |IA64
143
- | |ARM
144
- | |ARMTHUMB
145
- | |SPARC
146
-
147
- For further information about each of these flags, you will find reference at [XZ SDK](http://7-zip.org/sdk.html).
183
+ | Zlib | node-liblzma | Arguments |
184
+ |------|--------------|-----------|
185
+ | `createGzip` | `createXz` | `([options])` |
186
+ | `createGunzip` | `createUnxz` | `([options])` |
187
+ | `gzip` | `xz` | `(buf, [options], callback)` |
188
+ | `gunzip` | `unxz` | `(buf, [options], callback)` |
189
+ | `gzipSync` | `xzSync` | `(buf, [options])` |
190
+ | `gunzipSync` | `unxzSync` | `(buf, [options])` |
191
+ | - | `xzAsync` | `(buf, [options])` `Promise<Buffer>` |
192
+ | - | `unxzAsync` | `(buf, [options])` `Promise<Buffer>` |
193
+ | - | `xzFile` | `(input, output, [options])` → `Promise<void>` |
194
+ | - | `unxzFile` | `(input, output, [options])` → `Promise<void>` |
195
+
196
+ ## Options
197
+
198
+ The `options` object accepts the following attributes:
199
+
200
+ | Attribute | Type | Description | Values |
201
+ |-----------|------|-------------|--------|
202
+ | `check` | number | Integrity check | `check.NONE`, `check.CRC32`, `check.CRC64`, `check.SHA256` |
203
+ | `preset` | number | Compression level (0-9) | `preset.DEFAULT` (6), `preset.EXTREME` |
204
+ | `mode` | number | Compression mode | `mode.FAST`, `mode.NORMAL` |
205
+ | `threads` | number | Thread count | `0` = auto (all cores), `1` = single-threaded, `N` = N threads |
206
+ | `filters` | array | Filter chain | `filter.LZMA2`, `filter.X86`, `filter.ARM`, etc. |
207
+ | `chunkSize` | number | Processing chunk size | Default: 64KB |
208
+
209
+ For further information about each of these flags, see the [XZ SDK documentation](http://7-zip.org/sdk.html).
148
210
 
149
211
  ## Advanced Configuration
150
212
 
@@ -152,32 +214,63 @@ For further information about each of these flags, you will find reference at [X
152
214
 
153
215
  The library supports multi-threaded compression when built with `ENABLE_THREAD_SUPPORT=yes` (default). Thread support allows parallel compression on multi-core systems, significantly improving performance for large files.
154
216
 
155
- **Using threads in compression:**
217
+ **Thread values:**
218
+
219
+ | Value | Behavior |
220
+ |-------|----------|
221
+ | `0` | **Auto-detect**: use all available CPU cores |
222
+ | `1` | Single-threaded (default) |
223
+ | `N` | Use exactly N threads |
224
+
225
+ **Example:**
156
226
 
157
227
  ```typescript
158
- import { xz, createXz } from 'node-liblzma';
228
+ import { createXz, hasThreads } from 'node-liblzma';
159
229
 
160
- // Specify number of threads (1-N, where N is CPU core count)
161
- const options = {
162
- preset: lzma.preset.DEFAULT,
163
- threads: 4 // Use 4 threads for compression
164
- };
230
+ // Check if threading is available
231
+ if (hasThreads()) {
232
+ // Auto-detect: use all CPU cores
233
+ const compressor = createXz({ threads: 0 });
234
+
235
+ // Or specify exact thread count
236
+ const compressor4 = createXz({ threads: 4 });
237
+ }
238
+ ```
239
+
240
+ **Important notes:**
241
+ - Thread support only applies to **compression**, not decompression
242
+ - Requires LZMA library built with pthread support (`ENABLE_THREAD_SUPPORT=yes`)
243
+ - Default is `threads: 1` (single-threaded) for predictable behavior
244
+ - Check availability: `hasThreads()` returns `true` if multi-threading is supported
245
+
246
+ ### Progress Monitoring
247
+
248
+ Track compression and decompression progress in real-time:
249
+
250
+ ```typescript
251
+ import { createXz, createUnxz } from 'node-liblzma';
165
252
 
166
- // With buffer compression
167
- xz(buffer, options, (err, compressed) => {
168
- // ...
253
+ const compressor = createXz({ preset: 6 });
254
+
255
+ compressor.on('progress', ({ bytesRead, bytesWritten }) => {
256
+ const ratio = bytesWritten / bytesRead;
257
+ console.log(`Progress: ${bytesRead} bytes in, ${bytesWritten} bytes out (ratio: ${ratio.toFixed(2)})`);
258
+ });
259
+
260
+ // Works with both compression and decompression
261
+ const decompressor = createUnxz();
262
+ decompressor.on('progress', ({ bytesRead, bytesWritten }) => {
263
+ console.log(`Decompressing: ${bytesRead} → ${bytesWritten} bytes`);
169
264
  });
170
265
 
171
- // With streams
172
- const compressor = createXz(options);
173
266
  inputStream.pipe(compressor).pipe(outputStream);
174
267
  ```
175
268
 
176
- **Important notes:**
177
- - Thread support only applies to **compression**, not decompression
178
- - Requires LZMA library built with pthread support
179
- - `threads: 1` disables multi-threading (falls back to single-threaded encoder)
180
- - Check if threads are available: `import { hasThreads } from 'node-liblzma';`
269
+ **Notes:**
270
+ - Progress events fire after each chunk is processed
271
+ - `bytesRead`: Total input bytes processed so far
272
+ - `bytesWritten`: Total output bytes produced so far
273
+ - Works with streams, not buffer APIs (`xz`/`unxz`)
181
274
 
182
275
  ### Buffer Size Optimization
183
276
 
@@ -434,7 +527,7 @@ npm test
434
527
  pnpm test
435
528
  ```
436
529
 
437
- It will build and launch the test suite (51 tests) with [Vitest](https://vitest.dev/) with TypeScript support and coverage reporting.
530
+ It will build and launch the test suite (325+ tests) with [Vitest](https://vitest.dev/) with TypeScript support and coverage reporting.
438
531
 
439
532
  Additional testing commands:
440
533
 
package/binding.gyp CHANGED
@@ -122,8 +122,13 @@
122
122
  "hard_dependency": 1,
123
123
  "actions": [{
124
124
  "action_name": "download_and_extract_xz",
125
- "inputs": [""],
126
- "outputs": ["<(xz_vendor_dir)/CMakeLists.txt"],
125
+ "inputs": [
126
+ "<(module_root_dir)/xz-version.json",
127
+ "<(module_root_dir)/scripts/download_xz_from_github.py"
128
+ ],
129
+ "outputs": [
130
+ "<(xz_vendor_dir)/CMakeLists.txt"
131
+ ],
127
132
  "action": [
128
133
  "<(py3)",
129
134
  "<(module_root_dir)/scripts/download_xz_from_github.py",
package/index.d.ts CHANGED
@@ -67,19 +67,42 @@ export type FlagType = 'TELL_NO_CHECK' | 'TELL_UNSUPPORTED_CHECK' | 'TELL_ANY_CH
67
67
 
68
68
  export type CompressionCallback = (error: Error | null, result?: Buffer) => void;
69
69
 
70
+ /**
71
+ * Progress event data emitted during compression/decompression
72
+ */
73
+ export interface ProgressInfo {
74
+ /** Total bytes read from input so far */
75
+ bytesRead: number;
76
+ /** Total bytes written to output so far */
77
+ bytesWritten: number;
78
+ }
79
+
70
80
  export declare abstract class XzStream extends Transform {
71
81
  constructor(streamMode: number, opts?: LZMAOptions, options?: TransformOptions);
72
-
82
+
83
+ /** Total bytes read from input so far */
84
+ readonly bytesRead: number;
85
+
86
+ /** Total bytes written to output so far */
87
+ readonly bytesWritten: number;
88
+
73
89
  /** Flush the stream with specified flush type */
74
90
  flush(callback?: () => void): void;
75
91
  flush(kind: number, callback?: () => void): void;
76
-
92
+
77
93
  /** Close the stream */
78
94
  close(callback?: () => void): void;
79
-
95
+
80
96
  _transform(chunk: Buffer | null, encoding: string, callback: (error?: Error) => void): void;
81
97
  _flush(callback: () => void): void;
82
98
  protected _processChunk(chunk: Buffer | null, flushFlag: number, callback?: (error?: Error) => void): Buffer | undefined;
99
+
100
+ /**
101
+ * Listen for progress events
102
+ * @event progress Emitted when data is written to output
103
+ */
104
+ on(event: 'progress', listener: (info: ProgressInfo) => void): this;
105
+ on(event: string | symbol, listener: (...args: unknown[]) => void): this;
83
106
  }
84
107
 
85
108
  export declare class Xz extends XzStream {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAO3C;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;gBACrC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBACjC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;gBAC9B,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;gBACrC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAoC1E"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAO3C;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;gBACrC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBACjC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;gBAC9B,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;gBACrC,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CA6C1E"}
package/lib/errors.js CHANGED
@@ -94,19 +94,27 @@ export class LZMAProgrammingError extends LZMAError {
94
94
  * Factory function to create appropriate error instance based on errno
95
95
  */
96
96
  export function createLZMAError(errno, message) {
97
- // LZMA error codes mapping
98
- const LZMA_OK = 0;
99
- const LZMA_STREAM_END = 1;
100
- const LZMA_NO_CHECK = 2;
101
- const LZMA_UNSUPPORTED_CHECK = 3;
102
- const LZMA_GET_CHECK = 4;
103
- const LZMA_MEM_ERROR = 5;
104
- const LZMA_MEMLIMIT_ERROR = 6;
105
- const LZMA_FORMAT_ERROR = 7;
106
- const LZMA_OPTIONS_ERROR = 8;
107
- const LZMA_DATA_ERROR = 9;
108
- const LZMA_BUF_ERROR = 10;
109
- const LZMA_PROG_ERROR = 11;
97
+ // LZMA return codes mapping from liblzma/base.h:
98
+ // Codes 0-4 are success/informational status codes, not errors.
99
+ // They are handled by the default case below.
100
+ /* biome-ignore lint/correctness/noUnusedVariables: Kept for documentation - shows full lzma_ret enum range (0-11) */
101
+ const LZMA_OK = 0; // Operation completed successfully
102
+ /* biome-ignore lint/correctness/noUnusedVariables: Kept for documentation */
103
+ const LZMA_STREAM_END = 1; // End of stream reached
104
+ /* biome-ignore lint/correctness/noUnusedVariables: Kept for documentation */
105
+ const LZMA_NO_CHECK = 2; // Input stream has no integrity check
106
+ /* biome-ignore lint/correctness/noUnusedVariables: Kept for documentation */
107
+ const LZMA_UNSUPPORTED_CHECK = 3; // Cannot calculate integrity check
108
+ /* biome-ignore lint/correctness/noUnusedVariables: Kept for documentation */
109
+ const LZMA_GET_CHECK = 4; // Integrity check type now available
110
+ // Actual error codes (5-11) - these get specialized error classes:
111
+ const LZMA_MEM_ERROR = 5; // Cannot allocate memory
112
+ const LZMA_MEMLIMIT_ERROR = 6; // Memory usage limit reached
113
+ const LZMA_FORMAT_ERROR = 7; // File format not recognized
114
+ const LZMA_OPTIONS_ERROR = 8; // Invalid or unsupported options
115
+ const LZMA_DATA_ERROR = 9; // Data is corrupt
116
+ const LZMA_BUF_ERROR = 10; // No progress possible
117
+ const LZMA_PROG_ERROR = 11; // Programming error
110
118
  switch (errno) {
111
119
  case LZMA_MEM_ERROR:
112
120
  return new LZMAMemoryError(errno);
@@ -147,7 +155,10 @@ function getErrorMessage(errno) {
147
155
  'No progress is possible',
148
156
  'Programming error',
149
157
  ];
150
- const messageIndex = Math.max(0, Math.min(errno, messages.length - 1));
151
- return messages[messageIndex];
158
+ // F-011: Handle out-of-bounds errno explicitly instead of silent clamping
159
+ if (errno < 0 || errno >= messages.length) {
160
+ return `Unknown LZMA error code: ${errno}`;
161
+ }
162
+ return messages[errno];
152
163
  }
153
164
  //# sourceMappingURL=errors.js.map
package/lib/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;GAEG;AACH,MAAM,OAAO,SAAU,SAA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