node-liblzma 2.0.3 → 2.2.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.
- package/README.md +263 -67
- package/index.d.ts +60 -3
- package/lib/cli/nxz.d.ts +7 -0
- package/lib/cli/nxz.d.ts.map +1 -0
- package/lib/cli/nxz.js +486 -0
- package/lib/cli/nxz.js.map +1 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +26 -15
- package/lib/errors.js.map +1 -1
- package/lib/lzma.d.ts +319 -2
- package/lib/lzma.d.ts.map +1 -1
- package/lib/lzma.js +303 -39
- package/lib/lzma.js.map +1 -1
- package/lib/pool.d.ts.map +1 -1
- package/lib/pool.js +9 -3
- package/lib/pool.js.map +1 -1
- package/lib/types.d.ts +68 -1
- package/lib/types.d.ts.map +1 -1
- package/package.json +32 -12
- package/scripts/build_xz_with_cmake.py +23 -26
- package/src/bindings/module.cpp +196 -0
- package/src/bindings/node-liblzma.cpp +40 -4
- package/src/bindings/node-liblzma.hpp +2 -1
- package/xz-version.json +3 -3
- package/.gitattributes +0 -3
- package/.release-it.json +0 -7
- package/.release-it.manual.json +0 -7
- package/.release-it.retry.json +0 -3
- package/CHANGELOG.md +0 -271
- package/History.md +0 -79
- package/RELEASING.md +0 -131
- package/biome.json +0 -81
- package/pnpm-workspace.yaml +0 -3
- package/prebuilds/darwin-x64/node-liblzma.node +0 -0
- package/prebuilds/linux-x64/node-liblzma.node +0 -0
- package/prebuilds/win32-x64/node-liblzma.node +0 -0
- package/scripts/analyze-coverage.js +0 -132
- package/scripts/compare-coverage-tools.js +0 -93
- package/src/errors.ts +0 -167
- package/src/lzma.ts +0 -839
- package/src/pool.ts +0 -228
- package/src/types.ts +0 -30
- package/tsconfig.json +0 -50
- package/vitest.config.istanbul.ts +0 -29
- package/vitest.config.monocart.ts +0 -44
- package/vitest.config.ts +0 -52
package/README.md
CHANGED
|
@@ -3,8 +3,12 @@ Node-liblzma
|
|
|
3
3
|
|
|
4
4
|
[](https://npmjs.org/package/node-liblzma)
|
|
5
5
|
[](https://npmjs.org/package/node-liblzma)
|
|
6
|
-
[](https://github.com/oorabona/node-liblzma/actions/workflows/ci.yml)
|
|
7
|
+
[](https://oorabona.github.io/node-liblzma/)
|
|
8
|
+
[](https://github.com/oorabona/node-liblzma/blob/master/LICENSE)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
11
|
+
[](https://docs.npmjs.com/generating-provenance-statements)
|
|
8
12
|
|
|
9
13
|
# What is liblzma/XZ ?
|
|
10
14
|
|
|
@@ -30,8 +34,180 @@ See [installation](#installation) below.
|
|
|
30
34
|
> Only LZMA2 is supported for compression output.
|
|
31
35
|
But the library can open and read any LZMA1 or LZMA2 compressed file.
|
|
32
36
|
|
|
37
|
+
# Quick Start
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install node-liblzma
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { xzAsync, unxzAsync, createXz, createUnxz } from 'node-liblzma';
|
|
45
|
+
|
|
46
|
+
// Simple: Compress a buffer
|
|
47
|
+
const compressed = await xzAsync(Buffer.from('Hello, World!'));
|
|
48
|
+
const decompressed = await unxzAsync(compressed);
|
|
49
|
+
|
|
50
|
+
// Streaming: Compress a file
|
|
51
|
+
import { createReadStream, createWriteStream } from 'fs';
|
|
52
|
+
|
|
53
|
+
createReadStream('input.txt')
|
|
54
|
+
.pipe(createXz())
|
|
55
|
+
.pipe(createWriteStream('output.xz'));
|
|
56
|
+
|
|
57
|
+
// With progress monitoring
|
|
58
|
+
const compressor = createXz();
|
|
59
|
+
compressor.on('progress', ({ bytesRead, bytesWritten }) => {
|
|
60
|
+
console.log(`${bytesRead} bytes in → ${bytesWritten} bytes out`);
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Promise style (with `.then()`):**
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { xzAsync, unxzAsync } from 'node-liblzma';
|
|
68
|
+
|
|
69
|
+
xzAsync(Buffer.from('Hello, World!'))
|
|
70
|
+
.then(compressed => {
|
|
71
|
+
console.log('Compressed size:', compressed.length);
|
|
72
|
+
return unxzAsync(compressed);
|
|
73
|
+
})
|
|
74
|
+
.then(decompressed => {
|
|
75
|
+
console.log('Decompressed:', decompressed.toString());
|
|
76
|
+
})
|
|
77
|
+
.catch(err => {
|
|
78
|
+
console.error('Compression failed:', err);
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Callback style (Node.js traditional):**
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { xz, unxz } from 'node-liblzma';
|
|
86
|
+
|
|
87
|
+
xz(Buffer.from('Hello, World!'), (err, compressed) => {
|
|
88
|
+
if (err) throw err;
|
|
89
|
+
unxz(compressed, (err, decompressed) => {
|
|
90
|
+
if (err) throw err;
|
|
91
|
+
console.log('Decompressed:', decompressed.toString());
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
📖 **Full API documentation**: [oorabona.github.io/node-liblzma](https://oorabona.github.io/node-liblzma/)
|
|
97
|
+
|
|
98
|
+
# Command Line Interface (nxz)
|
|
99
|
+
|
|
100
|
+
This package includes `nxz`, a portable xz-like CLI tool that works on any platform with Node.js.
|
|
101
|
+
|
|
102
|
+
## Installation
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Global installation (recommended for CLI usage)
|
|
106
|
+
npm install -g node-liblzma
|
|
107
|
+
# or
|
|
108
|
+
pnpm add -g node-liblzma
|
|
109
|
+
|
|
110
|
+
# Then use directly
|
|
111
|
+
nxz --help
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Quick Examples
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Compress a file (creates file.txt.xz, deletes original)
|
|
118
|
+
nxz file.txt
|
|
119
|
+
|
|
120
|
+
# Decompress (auto-detected from .xz extension)
|
|
121
|
+
nxz file.txt.xz
|
|
122
|
+
|
|
123
|
+
# Keep original file (-k)
|
|
124
|
+
nxz -k file.txt
|
|
125
|
+
|
|
126
|
+
# Decompress explicitly (-d)
|
|
127
|
+
nxz -d archive.xz
|
|
128
|
+
|
|
129
|
+
# Maximum compression (-9) with extreme mode (-e)
|
|
130
|
+
nxz -9e large-file.bin
|
|
131
|
+
|
|
132
|
+
# Compress to stdout (-c) for piping
|
|
133
|
+
nxz -c file.txt > file.txt.xz
|
|
134
|
+
|
|
135
|
+
# Decompress to stdout
|
|
136
|
+
nxz -dc file.txt.xz | grep "pattern"
|
|
137
|
+
|
|
138
|
+
# Custom output file (-o)
|
|
139
|
+
nxz -d archive.xz -o /tmp/output.bin
|
|
140
|
+
|
|
141
|
+
# List archive info (-l)
|
|
142
|
+
nxz -l file.txt.xz
|
|
143
|
+
|
|
144
|
+
# Verbose info (-lv)
|
|
145
|
+
nxz -lv file.txt.xz
|
|
146
|
+
|
|
147
|
+
# Compress from stdin
|
|
148
|
+
cat file.txt | nxz -c > file.txt.xz
|
|
149
|
+
|
|
150
|
+
# Quiet mode - suppress warnings (-q)
|
|
151
|
+
nxz -q file.txt
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## All Options
|
|
155
|
+
|
|
156
|
+
| Option | Long | Description |
|
|
157
|
+
|--------|------|-------------|
|
|
158
|
+
| `-z` | `--compress` | Force compression mode |
|
|
159
|
+
| `-d` | `--decompress` | Force decompression mode |
|
|
160
|
+
| `-l` | `--list` | List archive information |
|
|
161
|
+
| `-k` | `--keep` | Keep original file (don't delete) |
|
|
162
|
+
| `-f` | `--force` | Overwrite existing output file |
|
|
163
|
+
| `-c` | `--stdout` | Write to stdout, keep original file |
|
|
164
|
+
| `-o` | `--output=FILE` | Write output to specified file |
|
|
165
|
+
| `-v` | `--verbose` | Show progress for large files |
|
|
166
|
+
| `-q` | `--quiet` | Suppress warning messages |
|
|
167
|
+
| `-0`..`-9` | | Compression level (default: 6) |
|
|
168
|
+
| `-e` | `--extreme` | Extreme compression (slower) |
|
|
169
|
+
| `-h` | `--help` | Show help |
|
|
170
|
+
| `-V` | `--version` | Show version |
|
|
171
|
+
|
|
172
|
+
## One-shot Usage (without global install)
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# npm/npx
|
|
176
|
+
npx --package node-liblzma nxz --help
|
|
177
|
+
npx -p node-liblzma nxz file.txt
|
|
178
|
+
|
|
179
|
+
# pnpm
|
|
180
|
+
pnpm dlx --package node-liblzma nxz --help
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Exit Codes
|
|
184
|
+
|
|
185
|
+
| Code | Meaning |
|
|
186
|
+
|------|---------|
|
|
187
|
+
| 0 | Success |
|
|
188
|
+
| 1 | Error (file not found, format error, etc.) |
|
|
189
|
+
| 130 | Interrupted (SIGINT/Ctrl+C) |
|
|
190
|
+
|
|
33
191
|
# What's new ?
|
|
34
192
|
|
|
193
|
+
## Latest Updates (2026)
|
|
194
|
+
|
|
195
|
+
* **CLI Tool (nxz)**: Portable xz-like command line tool included in the package
|
|
196
|
+
- Full xz compatibility: `-z`, `-d`, `-l`, `-k`, `-f`, `-c`, `-o`, `-v`, `-q`
|
|
197
|
+
- Compression presets 0-9 with extreme mode (`-e`)
|
|
198
|
+
- Progress display for large files, stdin/stdout piping
|
|
199
|
+
- Works on any platform with Node.js
|
|
200
|
+
- See [Command Line Interface](#command-line-interface-nxz) section
|
|
201
|
+
* **Progress Events**: Monitor compression/decompression progress with real-time events
|
|
202
|
+
```typescript
|
|
203
|
+
const compressor = createXz();
|
|
204
|
+
compressor.on('progress', ({ bytesRead, bytesWritten }) => {
|
|
205
|
+
console.log(`Read: ${bytesRead}, Written: ${bytesWritten}`);
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
* **API Documentation**: Full TypeDoc documentation with Material theme at [oorabona.github.io/node-liblzma](https://oorabona.github.io/node-liblzma/)
|
|
209
|
+
* **XZ Utils 5.8.2**: Updated to latest stable version
|
|
210
|
+
|
|
35
211
|
## Version 2.0 (2025) - Complete Modernization
|
|
36
212
|
|
|
37
213
|
This major release brings the library into 2025 with modern tooling and TypeScript support:
|
|
@@ -39,7 +215,7 @@ This major release brings the library into 2025 with modern tooling and TypeScri
|
|
|
39
215
|
* **Full TypeScript migration**: Complete rewrite from CoffeeScript to TypeScript for better type safety and developer experience
|
|
40
216
|
* **Promise-based APIs**: New async functions `xzAsync()` and `unxzAsync()` with Promise support
|
|
41
217
|
* **Modern testing**: Migrated from Mocha to Vitest with improved performance and better TypeScript integration
|
|
42
|
-
* **Enhanced tooling**:
|
|
218
|
+
* **Enhanced tooling**:
|
|
43
219
|
- [Biome](https://biomejs.dev/) for fast linting and formatting
|
|
44
220
|
- Pre-commit hooks with nano-staged and simple-git-hooks
|
|
45
221
|
- pnpm as package manager for better dependency management
|
|
@@ -75,11 +251,11 @@ Several prebuilt versions are bundled within the package.
|
|
|
75
251
|
|
|
76
252
|
If your OS/architecture matches, you will use this version which has been compiled using the following default flags:
|
|
77
253
|
|
|
78
|
-
Flag | Description | Default
|
|
79
|
-
|
|
80
|
-
USE_GLOBAL |
|
|
81
|
-
RUNTIME_LINK |
|
|
82
|
-
ENABLE_THREAD_SUPPORT |
|
|
254
|
+
| Flag | Description | Default | Values |
|
|
255
|
+
|------|-------------|---------|--------|
|
|
256
|
+
| `USE_GLOBAL` | Use system liblzma library | `yes` (`no` on Windows) | `yes`, `no` |
|
|
257
|
+
| `RUNTIME_LINK` | Static or shared linking | `shared` | `static`, `shared` |
|
|
258
|
+
| `ENABLE_THREAD_SUPPORT` | Enable thread support | `yes` | `yes`, `no` |
|
|
83
259
|
|
|
84
260
|
If not `node-gyp` will automagically start compiling stuff according to the environment variables set, or the default values above.
|
|
85
261
|
|
|
@@ -107,44 +283,33 @@ var lzma = require('node-liblzma');
|
|
|
107
283
|
import * as lzma from 'node-liblzma';
|
|
108
284
|
```
|
|
109
285
|
|
|
110
|
-
Zlib
|
|
111
|
-
|
|
112
|
-
createGzip
|
|
113
|
-
createGunzip
|
|
114
|
-
gzip
|
|
115
|
-
gunzip
|
|
116
|
-
gzipSync
|
|
117
|
-
gunzipSync
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
| |CRC64
|
|
130
|
-
| |
|
|
131
|
-
|
|
132
|
-
| |
|
|
133
|
-
|
|
134
|
-
| |
|
|
135
|
-
|
|
136
|
-
|
|
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).
|
|
286
|
+
| Zlib | node-liblzma | Arguments |
|
|
287
|
+
|------|--------------|-----------|
|
|
288
|
+
| `createGzip` | `createXz` | `([options])` |
|
|
289
|
+
| `createGunzip` | `createUnxz` | `([options])` |
|
|
290
|
+
| `gzip` | `xz` | `(buf, [options], callback)` |
|
|
291
|
+
| `gunzip` | `unxz` | `(buf, [options], callback)` |
|
|
292
|
+
| `gzipSync` | `xzSync` | `(buf, [options])` |
|
|
293
|
+
| `gunzipSync` | `unxzSync` | `(buf, [options])` |
|
|
294
|
+
| - | `xzAsync` | `(buf, [options])` → `Promise<Buffer>` |
|
|
295
|
+
| - | `unxzAsync` | `(buf, [options])` → `Promise<Buffer>` |
|
|
296
|
+
| - | `xzFile` | `(input, output, [options])` → `Promise<void>` |
|
|
297
|
+
| - | `unxzFile` | `(input, output, [options])` → `Promise<void>` |
|
|
298
|
+
|
|
299
|
+
## Options
|
|
300
|
+
|
|
301
|
+
The `options` object accepts the following attributes:
|
|
302
|
+
|
|
303
|
+
| Attribute | Type | Description | Values |
|
|
304
|
+
|-----------|------|-------------|--------|
|
|
305
|
+
| `check` | number | Integrity check | `check.NONE`, `check.CRC32`, `check.CRC64`, `check.SHA256` |
|
|
306
|
+
| `preset` | number | Compression level (0-9) | `preset.DEFAULT` (6), `preset.EXTREME` |
|
|
307
|
+
| `mode` | number | Compression mode | `mode.FAST`, `mode.NORMAL` |
|
|
308
|
+
| `threads` | number | Thread count | `0` = auto (all cores), `1` = single-threaded, `N` = N threads |
|
|
309
|
+
| `filters` | array | Filter chain | `filter.LZMA2`, `filter.X86`, `filter.ARM`, etc. |
|
|
310
|
+
| `chunkSize` | number | Processing chunk size | Default: 64KB |
|
|
311
|
+
|
|
312
|
+
For further information about each of these flags, see the [XZ SDK documentation](http://7-zip.org/sdk.html).
|
|
148
313
|
|
|
149
314
|
## Advanced Configuration
|
|
150
315
|
|
|
@@ -152,32 +317,63 @@ For further information about each of these flags, you will find reference at [X
|
|
|
152
317
|
|
|
153
318
|
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
319
|
|
|
155
|
-
**
|
|
320
|
+
**Thread values:**
|
|
321
|
+
|
|
322
|
+
| Value | Behavior |
|
|
323
|
+
|-------|----------|
|
|
324
|
+
| `0` | **Auto-detect**: use all available CPU cores |
|
|
325
|
+
| `1` | Single-threaded (default) |
|
|
326
|
+
| `N` | Use exactly N threads |
|
|
327
|
+
|
|
328
|
+
**Example:**
|
|
156
329
|
|
|
157
330
|
```typescript
|
|
158
|
-
import {
|
|
331
|
+
import { createXz, hasThreads } from 'node-liblzma';
|
|
159
332
|
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
333
|
+
// Check if threading is available
|
|
334
|
+
if (hasThreads()) {
|
|
335
|
+
// Auto-detect: use all CPU cores
|
|
336
|
+
const compressor = createXz({ threads: 0 });
|
|
337
|
+
|
|
338
|
+
// Or specify exact thread count
|
|
339
|
+
const compressor4 = createXz({ threads: 4 });
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**Important notes:**
|
|
344
|
+
- Thread support only applies to **compression**, not decompression
|
|
345
|
+
- Requires LZMA library built with pthread support (`ENABLE_THREAD_SUPPORT=yes`)
|
|
346
|
+
- Default is `threads: 1` (single-threaded) for predictable behavior
|
|
347
|
+
- Check availability: `hasThreads()` returns `true` if multi-threading is supported
|
|
348
|
+
|
|
349
|
+
### Progress Monitoring
|
|
165
350
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
351
|
+
Track compression and decompression progress in real-time:
|
|
352
|
+
|
|
353
|
+
```typescript
|
|
354
|
+
import { createXz, createUnxz } from 'node-liblzma';
|
|
355
|
+
|
|
356
|
+
const compressor = createXz({ preset: 6 });
|
|
357
|
+
|
|
358
|
+
compressor.on('progress', ({ bytesRead, bytesWritten }) => {
|
|
359
|
+
const ratio = bytesWritten / bytesRead;
|
|
360
|
+
console.log(`Progress: ${bytesRead} bytes in, ${bytesWritten} bytes out (ratio: ${ratio.toFixed(2)})`);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// Works with both compression and decompression
|
|
364
|
+
const decompressor = createUnxz();
|
|
365
|
+
decompressor.on('progress', ({ bytesRead, bytesWritten }) => {
|
|
366
|
+
console.log(`Decompressing: ${bytesRead} → ${bytesWritten} bytes`);
|
|
169
367
|
});
|
|
170
368
|
|
|
171
|
-
// With streams
|
|
172
|
-
const compressor = createXz(options);
|
|
173
369
|
inputStream.pipe(compressor).pipe(outputStream);
|
|
174
370
|
```
|
|
175
371
|
|
|
176
|
-
**
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
- `
|
|
180
|
-
-
|
|
372
|
+
**Notes:**
|
|
373
|
+
- Progress events fire after each chunk is processed
|
|
374
|
+
- `bytesRead`: Total input bytes processed so far
|
|
375
|
+
- `bytesWritten`: Total output bytes produced so far
|
|
376
|
+
- Works with streams, not buffer APIs (`xz`/`unxz`)
|
|
181
377
|
|
|
182
378
|
### Buffer Size Optimization
|
|
183
379
|
|
|
@@ -434,7 +630,7 @@ npm test
|
|
|
434
630
|
pnpm test
|
|
435
631
|
```
|
|
436
632
|
|
|
437
|
-
It will build and launch the test suite (
|
|
633
|
+
It will build and launch the test suite (325+ tests) with [Vitest](https://vitest.dev/) with TypeScript support and coverage reporting.
|
|
438
634
|
|
|
439
635
|
Additional testing commands:
|
|
440
636
|
|
|
@@ -837,9 +1033,9 @@ We follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
|
837
1033
|
|
|
838
1034
|
**Examples**:
|
|
839
1035
|
```bash
|
|
840
|
-
git commit -m "feat
|
|
841
|
-
git commit -m "fix
|
|
842
|
-
git commit -m "docs
|
|
1036
|
+
git commit -m "feat: add LZMAPool for concurrency control"
|
|
1037
|
+
git commit -m "fix: resolve memory leak in FunctionReference"
|
|
1038
|
+
git commit -m "docs: add migration guide for v2.0"
|
|
843
1039
|
```
|
|
844
1040
|
|
|
845
1041
|
## Pull Request Process
|
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 {
|
|
@@ -93,6 +116,40 @@ export declare class Unxz extends XzStream {
|
|
|
93
116
|
/** Check if threading support is available */
|
|
94
117
|
export declare function hasThreads(): boolean;
|
|
95
118
|
|
|
119
|
+
/** Check if a buffer starts with XZ magic bytes */
|
|
120
|
+
export declare function isXZ(buffer: Buffer): boolean;
|
|
121
|
+
|
|
122
|
+
/** Get the runtime liblzma version string (e.g., "5.4.1") */
|
|
123
|
+
export declare function versionString(): string;
|
|
124
|
+
|
|
125
|
+
/** Get the runtime liblzma version number (e.g., 50040010 for 5.4.1) */
|
|
126
|
+
export declare function versionNumber(): number;
|
|
127
|
+
|
|
128
|
+
/** Get memory usage estimate for encoding with given preset */
|
|
129
|
+
export declare function easyEncoderMemusage(presetLevel: number): number;
|
|
130
|
+
|
|
131
|
+
/** Get memory usage estimate for decoding */
|
|
132
|
+
export declare function easyDecoderMemusage(): number;
|
|
133
|
+
|
|
134
|
+
/** Metadata extracted from an XZ file index */
|
|
135
|
+
export interface XZFileIndex {
|
|
136
|
+
/** Uncompressed size in bytes */
|
|
137
|
+
uncompressedSize: number;
|
|
138
|
+
/** Compressed size in bytes (excluding headers) */
|
|
139
|
+
compressedSize: number;
|
|
140
|
+
/** Number of streams in the file */
|
|
141
|
+
streamCount: number;
|
|
142
|
+
/** Number of blocks in the file */
|
|
143
|
+
blockCount: number;
|
|
144
|
+
/** Integrity check type */
|
|
145
|
+
check: number;
|
|
146
|
+
/** Memory usage of the index structure */
|
|
147
|
+
memoryUsage: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Parse the index from a complete XZ file to get metadata */
|
|
151
|
+
export declare function parseFileIndex(buffer: Buffer): XZFileIndex;
|
|
152
|
+
|
|
96
153
|
/** Create a compression stream */
|
|
97
154
|
export declare function createXz(lzmaOptions?: LZMAOptions, options?: TransformOptions): Xz;
|
|
98
155
|
|
package/lib/cli/nxz.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nxz.d.ts","sourceRoot":"","sources":["../../src/cli/nxz.ts"],"names":[],"mappings":";AACA;;;GAGG"}
|