Skip to content

feat: support xz #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Currently supported:
- gzip
- tgz
- zip
- xz

## Install

Expand All @@ -33,7 +34,7 @@ npm install compressing

### Compress a single file

Use gzip as an example, tar, tgz and zip is same as gzip.
Use gzip as an example, tar, tgz, zip and xz is same as gzip.

__promise style__

Expand Down Expand Up @@ -235,6 +236,7 @@ Use this API to compress a single file. This is a convenient method, which wraps
- tar.compressFile(source, dest, opts)
- tgz.compressFile(source, dest, opts)
- zip.compressFile(source, dest, opts)
- xz.compressFile(source, dest, opts)

Params

Expand Down Expand Up @@ -268,6 +270,7 @@ Use this API to uncompress a file. This is a convenient method, which wraps Unco
- tgz.uncompress(source, dest, opts)
- zip.uncompress(source, dest, opts)
- gzip.uncompress(source, dest, opts)
- xz.uncompress(source, dest, opts)

Params

Expand All @@ -291,6 +294,7 @@ __Note: If you are not very familiar with streams, just use compressFile() API,
- new tar.FileStream(opts)
- new tgz.FileStream(opts)
- new zip.FileStream(opts)
- new xz.FileStream(opts)

Common params:

Expand All @@ -315,6 +319,10 @@ Zip params:
- opts.relativePath {String} - Adds a file from source into the compressed result file as opts.relativePath. Uncompression programs would extract the file from the compressed file as relativePath. If opts.source is a file path, opts.relativePath is optional, otherwise it's required.
- opts.yazl {Object} - zip.FileStream compression uses [yazl](https://github.com/thejoshwolfe/yazl), pass this param to control the behavior of yazl.

XZ params:

- opts.lzma - {Object} xz.FileStream uses lzma-native to compress, pass this param to control the behavior of lzma-native.

### Stream

The readable stream to compress anything as you need.
Expand Down Expand Up @@ -355,11 +363,20 @@ __Constructor__
- new tar.UncompressStream(opts)
- new tgz.UncompressStream(opts)
- new zip.UncompressStream(opts)
- new xz.UncompressStream(opts)

Common params:

- opts.source {String|Buffer|Stream} - source to be uncompressed, could be a file path, buffer, or a readable stream.

Gzip params:

- opts.zlib - {Object} gzip.UncompressStream uses zlib to uncompress, pass this param to control the behavior of zlib.

XZ params:

- opts.lzma - {Object} xz.UncompressStream uses lzma-native to uncompress, pass this param to control the behavior of lzma-native.

__CAUTION for zip.UncompressStream__

Due to the design of the .zip file format, it's impossible to interpret a .zip file without loading all data into memory.
Expand Down
22 changes: 22 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,25 @@ export namespace zip {
}

}

export namespace xz {
function compressFile(source: sourceType, dest: destType, opts?: any): Promise<void>
function uncompress(source: sourceType, dest: destType, opts?: any): Promise<void>
function decompress(source: sourceType, dest: destType, opts?: any): Promise<void>

export class FileStream extends ReadStream {
constructor(opts?: {
lzma?: object,
source: sourceType
});
}

export class UncompressStream extends WriteStream {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The xz.UncompressStream is defined as extending WriteStream. However, its JavaScript implementation (lib/xz/uncompress_stream.js) pipes the decompressed data out of itself (decompressor.pipe(this)), making it behave as a Readable stream. To ensure type correctness and consistency with its runtime behavior, this type definition should extend ReadStream.

Suggested change
export class UncompressStream extends WriteStream {
export class UncompressStream extends ReadStream {

constructor(opts?: {
lzma?: object,
source: sourceType
});
on(event: string, listener: (...args: any[]) => void): this
on(event: 'error', listener: (err: Error) => void): this
}
}
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ exports.zip = require('./lib/zip');
exports.gzip = require('./lib/gzip');
exports.tar = require('./lib/tar');
exports.tgz = require('./lib/tgz');
exports.xz = require('./lib/xz');
54 changes: 54 additions & 0 deletions lib/xz/file_stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';

const fs = require('fs');
const lzma = require('lzma-native');
const utils = require('../utils');
const streamifier = require('streamifier');
const stream = require('stream');

class XzFileStream extends stream.Transform {
constructor(opts) {
opts = opts || {};
super(opts);

const sourceType = utils.sourceType(opts.source);
const compressor = lzma.createCompressor(opts.lzma);

compressor.on('error', err => this.emit('error', err));
compressor.on('end', () => this.push(null));
compressor.on('data', chunk => this.push(chunk));

if (sourceType === 'file') {
const stream = fs.createReadStream(opts.source, opts.fs);
stream.on('error', err => this.emit('error', err));
stream.pipe(compressor);
return;
}

if (sourceType === 'buffer') {
const stream = streamifier.createReadStream(opts.source, opts.streamifier);
stream.on('error', err => this.emit('error', err));
stream.pipe(compressor);
return;
}

if (sourceType === 'stream') {
opts.source.on('error', err => this.emit('error', err));
opts.source.pipe(compressor);
return;
}

// For streaming input
this.on('pipe', srcStream => {
srcStream.unpipe(srcStream);
srcStream.pipe(compressor);
});
}

_transform(chunk, encoding, callback) {
// This will be handled by the compressor stream
callback();
}
}

module.exports = XzFileStream;

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 16)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 14)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 16)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 14)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 14)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 16)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Trailing spaces not allowed

Check failure on line 54 in lib/xz/file_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Trailing spaces not allowed
11 changes: 11 additions & 0 deletions lib/xz/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const utils = require('../utils');
const XzFileStream = require('./file_stream');
const XzUncompressStream = require('./uncompress_stream');

exports.FileStream = XzFileStream;
exports.UncompressStream = XzUncompressStream;
exports.compressFile = utils.makeFileProcessFn(XzFileStream);
exports.uncompress = utils.makeFileProcessFn(XzUncompressStream);
Copy link
Preview

Copilot AI May 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The decompress alias duplicates uncompress without a documented difference. Consider removing it or adding documentation for why both names exist.

Suggested change
exports.compressFile = utils.makeFileProcessFn(XzFileStream);
exports.uncompress = utils.makeFileProcessFn(XzUncompressStream);
exports.compressFile = utils.makeFileProcessFn(XzFileStream);
// Alias for decompressing files. Provided for consistency with other APIs that use "uncompress".
exports.uncompress = utils.makeFileProcessFn(XzUncompressStream);
// Alias for decompressing files. Provided for developer preference and readability.

Copilot uses AI. Check for mistakes.

exports.decompress = utils.makeFileProcessFn(XzUncompressStream);

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 16)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 14)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 16)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 14)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 14)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 16)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Trailing spaces not allowed

Check failure on line 11 in lib/xz/index.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Trailing spaces not allowed
49 changes: 49 additions & 0 deletions lib/xz/uncompress_stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';

const fs = require('fs');
const lzma = require('lzma-native');
const utils = require('../utils');
const streamifier = require('streamifier');
const { PassThrough } = require('stream');

class XzUncompressStream extends PassThrough {
constructor(opts) {
opts = opts || {};
super(opts);

const sourceType = utils.sourceType(opts.source);
const decompressor = lzma.createDecompressor(opts.lzma);

decompressor.on('error', err => this.emit('error', err));
decompressor.on('end', () => this.end());

// Handle single file decompression
if (sourceType === 'file') {
const stream = fs.createReadStream(opts.source, opts.fs);
stream.on('error', err => this.emit('error', err));
stream.pipe(decompressor).pipe(this);
return;
}

if (sourceType === 'buffer') {
const stream = streamifier.createReadStream(opts.source, opts.streamifier);
stream.on('error', err => this.emit('error', err));
stream.pipe(decompressor).pipe(this);
return;
}

if (sourceType === 'stream') {
opts.source.on('error', err => this.emit('error', err));
opts.source.pipe(decompressor).pipe(this);
return;
}

// For streaming input
this.on('pipe', srcStream => {
srcStream.unpipe(srcStream);
srcStream.pipe(decompressor).pipe(this);
});
}
}

module.exports = XzUncompressStream;

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 16)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 14)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 16)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 14)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 14)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 16)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Trailing spaces not allowed

Check failure on line 49 in lib/xz/uncompress_stream.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Trailing spaces not allowed
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"flushwritable": "^1.0.0",
"get-ready": "^1.0.0",
"iconv-lite": "^0.5.0",
"lzma-native": "^8.0.5",
Copy link

@coderabbitai coderabbitai bot May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify the lzma-native dependency version for security and compatibility.

The addition of lzma-native dependency looks correct for XZ compression support. However, please verify this version is secure and compatible with the target Node.js versions.


🌐 Web query:

What is the latest version of lzma-native npm package and are there any known security vulnerabilities in version 8.0.5?

💡 Result:

The latest version of lzma-native npm package is 8.0.6, which was published approximately 3 years ago (as of January 2022)[1].

As for lzma-native version 8.0.5, there is some security information available. According to ReversingLabs Spectra Assure Community, the package is not widely used, having about 20 million recorded downloads. However, they caution that a package's popularity is not necessarily an indicator of its safety[4].

While there are no direct vulnerabilities explicitly mentioned for lzma-native version 8.0.5 specifically, it's important to note that the underlying liblzma library (which lzma-native provides bindings to) has had a significant security issue. In early 2024, a critical vulnerability known as CVE-2024-3094 was discovered in the xz/liblzma library[6][7]. This vulnerability resulted from a supply chain attack where malicious code was embedded in the form of .m4 files in tarball distributions.

The vulnerability affected primarily versions 5.6.0 and 5.6.1 of the xz/liblzma library, with the backdoor specifically targeting systems running SSH servers and using liblzma[7]. However, according to available information, lzma-native appears to come with binary version 5.2.3, which is considered safe from this particular vulnerability[8].

For any npm package, it's generally recommended to run security audits using tools like npm audit to check for vulnerabilities in your dependencies[9]. This can help identify known security issues and provide remediation steps.

Citations:


Upgrade lzma-native to 8.0.6 and audit for security

The current dependency (8.0.5) bundles liblzma 5.2.3, which isn’t affected by CVE-2024-3094, and there are no known vulnerabilities in 8.0.5. However, the latest published version is 8.0.6, which may contain important fixes or improvements.

• In package.json (line 45), change
"lzma-native": "^8.0.5",
to
"lzma-native": "^8.0.6",
• After updating, run npm audit to catch any transitive issues.
• Verify compatibility with your supported Node.js versions.

🤖 Prompt for AI Agents
In package.json at line 45, update the lzma-native dependency version from
"^8.0.5" to "^8.0.6" to use the latest published version. After this change, run
`npm audit` to check for any security vulnerabilities in this or transitive
dependencies. Finally, verify that the updated version remains compatible with
the Node.js versions your project supports.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please change it

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fengmk2 I'll plan the code change to update the lzma-native dependency version. Another agent will come along and actually execute the changes.

flowchart TB
    A["Update lzma-native dependency"]
    A --> B["Modify package.json"]
    B --> C["Change version from ^8.0.5 to ^8.0.6"]
Loading

⏳ Preparing changes...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A summary of the edits CodeRabbit can apply:

The lzma-native dependency version in package.json will be updated from "^8.0.5" to "^8.0.6".

A plan of each step that CodeRabbit will take in order to execute the edits for each file (with inline rough draft snippets):

✏️ package.json

Open package.json and navigate to line 45, which currently reads:

"lzma-native": "^8.0.5",

Replace the version string on line 45 with the updated version:

-"lzma-native": "^8.0.5",
+"lzma-native": "^8.0.6",

Save your changes to package.json.


Run npm install to update package-lock.json and install lzma-native@^8.0.6.


Execute npm audit to identify any security vulnerabilities in the updated dependency tree.


Run the full test suite, including any compression/uncompression integration tests, to verify compatibility with the supported Node.js versions.

A summary of the context that CodeRabbit is considering across the codebase:

We need to pinpoint the exact location of the lzma-native dependency in package.json so we can update it precisely.

  • ✅ Create PR with these edits
  • 📌 Create commit in current branch
  • 📋 Get copyable edits

"mkdirp": "^0.5.1",
"pump": "^3.0.0",
"streamifier": "^0.1.1",
Expand Down
Binary file added test/fixtures/xx.log.xz
Binary file not shown.
91 changes: 91 additions & 0 deletions test/xz/file_stream.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const compressing = require('../..');

describe('test/xz/file_stream.test.js', () => {
const sourceFile = path.join(__dirname, '../fixtures/xx.log');
const xzFile = path.join(__dirname, '../fixtures/xx.log.xz');

it('should compress file to xz', done => {
const dest = path.join(__dirname, '../fixtures/xx.log.xz.tmp');
compressing.xz.compressFile(sourceFile, dest)
.then(() => {
assert(fs.existsSync(dest));
// 文件大小应该小于原始文件
assert(fs.statSync(dest).size < fs.statSync(sourceFile).size);
fs.unlinkSync(dest);
done();
})
.catch(done);
});

it('should decompress xz file to log', done => {
const dest = path.join(__dirname, '../fixtures/xx.log.tmp');
compressing.xz.uncompress(xzFile, dest)
.then(() => {
assert(fs.existsSync(dest));
// 内容应该一致
const raw = fs.readFileSync(sourceFile);
const out = fs.readFileSync(dest);
assert(raw.equals(out));
fs.unlinkSync(dest);
done();
})
.catch(done);
});

it('should compress buffer to xz', done => {
const buf = fs.readFileSync(sourceFile);
const dest = path.join(__dirname, '../fixtures/xx.log.xz.tmp');
compressing.xz.compressFile(buf, dest)
.then(() => {
assert(fs.existsSync(dest));
fs.unlinkSync(dest);
done();
})
.catch(done);
});

it('should decompress xz buffer to log', done => {
const buf = fs.readFileSync(xzFile);
const dest = path.join(__dirname, '../fixtures/xx.log.tmp');
compressing.xz.uncompress(buf, dest)
.then(() => {
assert(fs.existsSync(dest));
const raw = fs.readFileSync(sourceFile);
const out = fs.readFileSync(dest);
assert(raw.equals(out));
fs.unlinkSync(dest);
done();
})
.catch(done);
});

it('should compress stream to xz', done => {
const src = fs.createReadStream(sourceFile);
const dest = path.join(__dirname, '../fixtures/xx.log.xz.tmp');
compressing.xz.compressFile(src, dest)
.then(() => {
assert(fs.existsSync(dest));
fs.unlinkSync(dest);
done();
})
.catch(done);
});

it('should decompress xz stream to log', done => {
const src = fs.createReadStream(xzFile);
const dest = path.join(__dirname, '../fixtures/xx.log.tmp');
compressing.xz.uncompress(src, dest)
.then(() => {
assert(fs.existsSync(dest));
const raw = fs.readFileSync(sourceFile);
const out = fs.readFileSync(dest);
assert(raw.equals(out));
fs.unlinkSync(dest);
done();
})
.catch(done);
});
});

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 16)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 14)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 24)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 16)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 18)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 20)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 22)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 24)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 18)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (ubuntu-latest, 22)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 14)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 22)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 14)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 20)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 16)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 24)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (windows-latest, 18)

Trailing spaces not allowed

Check failure on line 91 in test/xz/file_stream.test.js

View workflow job for this annotation

GitHub Actions / Node.js / Test (macos-latest, 20)

Trailing spaces not allowed
Loading