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

feat: support xz #112

wants to merge 11 commits into from

Conversation

fengmk2
Copy link
Member

@fengmk2 fengmk2 commented May 24, 2025

closes #96

All codes gen by cursor

Summary by CodeRabbit

  • New Features
    • Added support for the "xz" compression format, enabling compression and decompression of files and streams using xz/LZMA.
    • Extended the API with xz-specific methods and streaming interfaces for file compression and decompression.
  • Documentation
    • Updated documentation to include xz support, with usage examples and API references.
  • Tests
    • Added tests to verify xz compression and decompression functionality across various input types.

closes #96

All codes gen by cursor
@fengmk2 fengmk2 requested a review from Copilot May 24, 2025 03:54
Copy link

coderabbitai bot commented May 24, 2025

Warning

Rate limit exceeded

@fengmk2 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 5 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b167355 and d6a07f0.

📒 Files selected for processing (2)
  • lib/xz/uncompress_stream.js (1 hunks)
  • test/xz/file_stream.test.js (1 hunks)

Walkthrough

Support for the XZ compression format has been added. This includes new APIs, streaming classes, and documentation for compressing and decompressing files and streams using XZ/LZMA. The package now depends on lzma-native, and comprehensive tests for XZ functionality are included.

Changes

File(s) Change Summary
README.md Documented XZ format support, usage examples, API, and options.
index.d.ts Declared xz namespace, functions, and stream classes for XZ compression/decompression.
index.js, lib/xz/index.js Exported XZ API and stream classes; wired up file processing functions for XZ.
lib/xz/file_stream.js, lib/xz/uncompress_stream.js Implemented XzFileStream and XzUncompressStream for XZ compression and decompression streams.
package.json Added lzma-native dependency.
test/xz/file_stream.test.js Added tests for XZ compression and decompression covering files, buffers, and streams.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant XzAPI as xz.compressFile / xz.uncompress
    participant FileStream as XzFileStream / XzUncompressStream
    participant lzma as lzma-native
    participant FS as File System

    User->>XzAPI: Call compressFile(source, dest, opts)
    XzAPI->>FileStream: Instantiate with source, opts
    FileStream->>lzma: Create compressor/decompressor stream
    FileStream->>FS: Read from source (file/buffer/stream)
    FS-->>FileStream: Source data
    FileStream->>lzma: Pipe data through compressor/decompressor
    lzma-->>FileStream: Compressed/decompressed data
    FileStream->>FS: Write to destination
    FS-->>User: Result (Promise resolved)
Loading

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Add .xz support for compression and decompression (#96)

Poem

A hop and a zip, now XZ joins the crew,
With streams and buffers, it knows what to do!
LZMA magic, in files big and small,
Compress, decompress—now we handle it all.
🐇✨
Hooray for new formats, the rabbit’s delight,
With XZ support, the future is bright!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

socket-security bot commented May 24, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedlzma-native@​8.0.610010010077100

View full report

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for xz compression and decompression, including corresponding tests, documentation updates, and library implementations.

  • Added xz-related stream implementations for compression and decompression
  • Updated tests and README to include xz usage
  • Added dependency on lzma-native in package.json

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/xz/file_stream.test.js New tests for xz compression/decompression covering file, buffer, and stream inputs
package.json Added lzma-native dependency
lib/xz/uncompress_stream.js Implementation of an uncompress stream for xz with potential pipe logic issue
lib/xz/index.js Exports for xz functionality
lib/xz/file_stream.js Xz file stream implementation for compression
index.js Updated to export new xz module
README.md Documentation updated to include xz usage

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (8)
test/xz/file_stream.test.js (1)

91-91: Fix trailing spaces.

Remove the trailing spaces at the end of line 91 to resolve the linting failures.

-}); 
+});
🧰 Tools
🪛 GitHub Check: Node.js / Test (macos-latest, 20)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 18)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 20)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 14)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 24)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 16)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 18)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 20)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 22)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 16)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 24)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 24)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 14)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 22)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 18)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 14)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 22)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 16)

[failure] 91-91:
Trailing spaces not allowed

lib/xz/index.js (2)

1-1: Remove redundant 'use strict' directive.

In modern Node.js modules, the 'use strict' directive is automatically applied and is redundant.

-'use strict';
-
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)


11-11: Fix trailing spaces.

Remove the trailing spaces at the end of line 11 to resolve the linting failures.

-exports.decompress = utils.makeFileProcessFn(XzUncompressStream); 
+exports.decompress = utils.makeFileProcessFn(XzUncompressStream);
🧰 Tools
🪛 GitHub Check: Node.js / Test (macos-latest, 20)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 18)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 20)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 14)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 24)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 16)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 18)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 20)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 22)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 16)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 24)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 24)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 14)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 22)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 18)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 14)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 22)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 16)

[failure] 11-11:
Trailing spaces not allowed

lib/xz/file_stream.js (2)

1-1: Remove redundant strict mode directive.

The 'use strict'; directive is redundant in ES modules as they are automatically in strict mode.

-'use strict';
-
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)


54-54: Remove trailing spaces.

Multiple CI checks are failing due to trailing spaces at the end of line 54.

-module.exports = XzFileStream; 
+module.exports = XzFileStream;
🧰 Tools
🪛 GitHub Check: Node.js / Test (macos-latest, 20)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 18)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 20)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 14)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 24)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 16)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 18)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 20)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 22)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 16)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 24)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 24)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 14)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 22)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 18)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 14)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 22)

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 16)

[failure] 54-54:
Trailing spaces not allowed

lib/xz/uncompress_stream.js (2)

1-1: Remove redundant strict mode directive.

The 'use strict'; directive is redundant in ES modules as they are automatically in strict mode.

-'use strict';
-
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)


49-49: Remove trailing spaces.

Multiple CI checks are failing due to trailing spaces at the end of line 49.

-module.exports = XzUncompressStream; 
+module.exports = XzUncompressStream;
🧰 Tools
🪛 GitHub Check: Node.js / Test (macos-latest, 20)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 18)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 20)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 14)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 24)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 16)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 18)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 20)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 22)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 16)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 24)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 24)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 14)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 22)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 18)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 14)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 22)

[failure] 49-49:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 16)

[failure] 49-49:
Trailing spaces not allowed

README.md (1)

37-37: Fix grammar issue.

The verb agreement is incorrect in this sentence.

-Use gzip as an example, tar, tgz, zip and xz is same as gzip.
+Use gzip as an example, tar, tgz, zip and xz are the same as gzip.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~37-~37: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...zip as an example, tar, tgz, zip and xz is same as gzip. promise style ```js...

(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9478897 and b104f8f.

⛔ Files ignored due to path filters (1)
  • test/fixtures/xx.log.xz is excluded by !**/*.xz
📒 Files selected for processing (8)
  • README.md (7 hunks)
  • index.d.ts (1 hunks)
  • index.js (1 hunks)
  • lib/xz/file_stream.js (1 hunks)
  • lib/xz/index.js (1 hunks)
  • lib/xz/uncompress_stream.js (1 hunks)
  • package.json (1 hunks)
  • test/xz/file_stream.test.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
lib/xz/uncompress_stream.js (3)
lib/xz/file_stream.js (5)
  • fs (3-3)
  • lzma (4-4)
  • utils (5-5)
  • streamifier (6-6)
  • stream (7-7)
test/xz/file_stream.test.js (1)
  • fs (1-1)
lib/xz/index.js (2)
  • utils (3-3)
  • XzUncompressStream (5-5)
🪛 Biome (1.9.4)
lib/xz/index.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

lib/xz/uncompress_stream.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

lib/xz/file_stream.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

🪛 GitHub Check: Node.js / Test (macos-latest, 20)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 18)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 20)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 14)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 24)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 16)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 18)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 20)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 22)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 16)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 24)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 24)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 14)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 22)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 18)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 14)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 22)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 16)
lib/xz/index.js

[failure] 11-11:
Trailing spaces not allowed

test/xz/file_stream.test.js

[failure] 91-91:
Trailing spaces not allowed

lib/xz/uncompress_stream.js

[failure] 49-49:
Trailing spaces not allowed

lib/xz/file_stream.js

[failure] 54-54:
Trailing spaces not allowed

🪛 LanguageTool
README.md

[uncategorized] ~37-~37: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...zip as an example, tar, tgz, zip and xz is same as gzip. promise style ```js...

(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)

🔇 Additional comments (7)
index.js (1)

7-7: LGTM! Clean and consistent API integration.

The XZ export follows the same pattern as other compression formats and integrates cleanly with the existing API structure.

test/xz/file_stream.test.js (1)

6-91: Excellent test coverage and structure.

The test suite provides comprehensive coverage for XZ compression/decompression functionality:

  • Tests different input types (file paths, buffers, streams)
  • Validates both compression and decompression operations
  • Includes proper assertions for file existence and content verification
  • Implements good cleanup practices for temporary files
  • Uses appropriate async/await patterns with error handling
🧰 Tools
🪛 GitHub Check: Node.js / Test (macos-latest, 20)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 18)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 20)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 14)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 24)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 16)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 18)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 20)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 22)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 16)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 24)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 24)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 14)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 22)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 18)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 14)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 22)

[failure] 91-91:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 16)

[failure] 91-91:
Trailing spaces not allowed

lib/xz/index.js (1)

3-11: Well-structured XZ module implementation.

The module follows the established patterns in the library:

  • Clean imports and exports structure
  • Consistent use of utils.makeFileProcessFn for file operations
  • Provides both class exports and convenience functions
  • The decompress alias alongside uncompress provides good API flexibility
🧰 Tools
🪛 GitHub Check: Node.js / Test (macos-latest, 20)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 18)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 20)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 14)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 24)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 16)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 18)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 20)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 22)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 16)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 24)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 24)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 14)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 22)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 18)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (macos-latest, 14)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (ubuntu-latest, 22)

[failure] 11-11:
Trailing spaces not allowed

🪛 GitHub Check: Node.js / Test (windows-latest, 16)

[failure] 11-11:
Trailing spaces not allowed

README.md (3)

25-25: LGTM! XZ format added to supported formats.

The addition of XZ to the supported formats list is correctly placed and maintains consistency with the existing documentation structure.


239-239: Excellent API documentation coverage.

The XZ API documentation is comprehensive and follows the established pattern for other compression formats. All key methods and classes are properly documented.

Also applies to: 273-273, 297-297, 366-366


322-325: Well-documented XZ-specific parameters.

The documentation for XZ-specific parameters (opts.lzma) is clear and follows the same structure as other format-specific options. This will help users understand how to configure the underlying lzma-native library.

Also applies to: 372-379

index.d.ts (1)

203-223: Excellent TypeScript definitions for XZ namespace.

The XZ namespace definitions are comprehensive and follow the exact same pattern as existing compression formats. The type definitions properly cover:

  • All async functions with correct Promise return types
  • Both FileStream and UncompressStream classes with proper inheritance
  • Correct constructor options including the lzma configuration parameter
  • Proper event listener overloads for error handling

This maintains excellent type safety and API consistency across all compression formats.

package.json Outdated
@@ -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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
lib/xz/file_stream.js (1)

43-43: ⚠️ Potential issue

Fix critical bug in pipe event handler.

The pipe event handler incorrectly calls srcStream.unpipe(srcStream) which tries to unpipe the stream from itself. This should be srcStream.unpipe(this) to properly unpipe the source from the current stream.

-      srcStream.unpipe(srcStream);
+      srcStream.unpipe(this);
lib/xz/uncompress_stream.js (1)

43-43: ⚠️ Potential issue

Fix critical bug in pipe event handler.

The pipe event handler incorrectly calls srcStream.unpipe(srcStream) which tries to unpipe the stream from itself. This should be srcStream.unpipe(this) to properly unpipe the source from the current stream.

-      srcStream.unpipe(srcStream);
+      srcStream.unpipe(this);
🧹 Nitpick comments (3)
lib/xz/index.js (1)

1-1: Remove redundant 'use strict' directive.

In ES modules (which Node.js treats all .js files as by default in modern versions), strict mode is automatically enabled. The 'use strict' directive is redundant and can be removed.

-'use strict';
-
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

lib/xz/file_stream.js (1)

1-1: Remove redundant 'use strict' directive.

In ES modules, strict mode is automatically enabled. The 'use strict' directive is redundant and can be removed.

-'use strict';
-
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

lib/xz/uncompress_stream.js (1)

1-1: Remove redundant 'use strict' directive.

In ES modules, strict mode is automatically enabled. The 'use strict' directive is redundant and can be removed.

-'use strict';
-
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b104f8f and 58055ea.

📒 Files selected for processing (4)
  • lib/xz/file_stream.js (1 hunks)
  • lib/xz/index.js (1 hunks)
  • lib/xz/uncompress_stream.js (1 hunks)
  • test/xz/file_stream.test.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/xz/file_stream.test.js
🧰 Additional context used
🧬 Code Graph Analysis (2)
lib/xz/file_stream.js (3)
lib/xz/uncompress_stream.js (5)
  • fs (3-3)
  • require (7-7)
  • lzma (4-4)
  • utils (5-5)
  • streamifier (6-6)
test/xz/file_stream.test.js (1)
  • fs (1-1)
lib/xz/index.js (2)
  • utils (3-3)
  • XzFileStream (4-4)
lib/xz/uncompress_stream.js (3)
lib/xz/file_stream.js (5)
  • fs (3-3)
  • lzma (4-4)
  • utils (5-5)
  • streamifier (6-6)
  • stream (7-7)
test/xz/file_stream.test.js (1)
  • fs (1-1)
lib/xz/index.js (2)
  • utils (3-3)
  • XzUncompressStream (5-5)
🪛 Biome (1.9.4)
lib/xz/file_stream.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

lib/xz/index.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

lib/xz/uncompress_stream.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

🔇 Additional comments (4)
lib/xz/index.js (1)

3-11: LGTM! Clean module structure.

The module structure is well-organized with clear imports and exports. The use of utils.makeFileProcessFn to create file processing functions maintains consistency with the existing codebase architecture.

lib/xz/file_stream.js (2)

9-46: Well-structured compression stream with proper error handling.

The implementation correctly handles different input types and delegates compression to the lzma compressor stream. Error propagation is properly set up for all stream sources.


48-51: Appropriate _transform implementation.

The empty _transform method is correct here since the actual compression work is delegated to the compressor stream. This follows the intended design pattern.

lib/xz/uncompress_stream.js (1)

9-46: Well-implemented decompression stream.

The decompression implementation correctly uses PassThrough stream and handles different input types appropriately. Error handling is properly implemented across all stream sources.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@fengmk2 fengmk2 requested a review from Copilot May 25, 2025 02:55
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the XZ (LZMA) compression format throughout the library.

  • Introduces lib/xz module with file- and stream-based compression/decompression using lzma-native
  • Registers xz in package.json, index.js, and updates README.md with usage and API docs
  • Adds end-to-end tests under test/xz covering files, buffers, and streams

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/xz/file_stream.test.js Tests for compressing/decompressing files, buffers, and streams using compressing.xz
package.json Added lzma-native dependency
lib/xz/uncompress_stream.js New XzUncompressStream implementation
lib/xz/file_stream.js New XzFileStream implementation
lib/xz/index.js Exports for XZ API surface (compressFile, uncompress, decompress, etc.)
index.js Registers exports.xz
README.md Documentation and examples updated to include XZ support
Comments suppressed due to low confidence (1)

lib/xz/uncompress_stream.js:48

  • There's an extra closing brace at the end of this file, which causes a syntax error. Remove the redundant '}' on line 48.
}

lib/xz/index.js Outdated
Comment on lines 9 to 10
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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
lib/xz/uncompress_stream.js (1)

42-45: ⚠️ Potential issue

Fix critical bug in pipe event handler.

The pipe event handler contains the same critical issue previously identified by other reviewers.

Apply this fix:

-      srcStream.unpipe(srcStream);
+      srcStream.unpipe(this);
🧹 Nitpick comments (1)
lib/xz/uncompress_stream.js (1)

1-1: Remove redundant 'use strict' directive.

JavaScript modules automatically operate in strict mode, making this directive unnecessary.

-'use strict';
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 58055ea and 9b17e98.

📒 Files selected for processing (1)
  • lib/xz/uncompress_stream.js (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
lib/xz/uncompress_stream.js

[error] 47-48: Expected a statement but instead found '}'.

Expected a statement here.

(parse)


[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Node.js / Test (windows-latest, 18)
🔇 Additional comments (2)
lib/xz/uncompress_stream.js (2)

9-41: Well-structured decompression implementation.

The class properly handles different source types with appropriate error propagation and follows good streaming patterns. The separation of logic for file, buffer, and stream sources is clean and maintainable.


17-18: Excellent error handling and stream lifecycle management.

The implementation correctly re-emits errors from the decompressor and properly handles the end event to close the output stream. This follows Node.js streaming best practices.

fengmk2 and others added 2 commits May 25, 2025 11:07
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
lib/xz/index.js (1)

55-55: Duplicate alias without clear differentiation.

This duplicates the existing concern about the decompress alias. As noted in previous reviews, consider removing this alias or adding documentation to explain why both uncompress and decompress names exist.

🧹 Nitpick comments (2)
lib/xz/index.js (1)

1-1: Remove redundant 'use strict' directive.

Modern JavaScript modules are automatically in strict mode, making this directive unnecessary.

-'use strict';
-
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

lib/xz/uncompress_stream.js (1)

1-1: Remove redundant 'use strict' directive.

Modern JavaScript modules are automatically in strict mode, making this directive unnecessary.

-'use strict';
-
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b17e98 and ee421a6.

📒 Files selected for processing (4)
  • README.md (6 hunks)
  • lib/xz/index.js (1 hunks)
  • lib/xz/uncompress_stream.js (1 hunks)
  • package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • package.json
  • README.md
🧰 Additional context used
🧬 Code Graph Analysis (2)
lib/xz/index.js (2)
lib/xz/file_stream.js (1)
  • utils (5-5)
lib/xz/uncompress_stream.js (2)
  • utils (5-5)
  • require (7-7)
lib/xz/uncompress_stream.js (2)
lib/xz/file_stream.js (5)
  • fs (3-3)
  • lzma (4-4)
  • utils (5-5)
  • streamifier (6-6)
  • stream (7-7)
lib/xz/index.js (2)
  • utils (3-3)
  • XzUncompressStream (6-6)
🪛 Biome (1.9.4)
lib/xz/index.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

lib/xz/uncompress_stream.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

🔇 Additional comments (5)
lib/xz/index.js (2)

8-21: Well-designed dependency checking pattern.

The implementation correctly handles the optional lzma-native dependency with proper error checking and informative error messages. The separation between checking and throwing allows for flexible usage patterns.


24-31: Effective lazy loading implementation.

The lazy loading pattern ensures that the optional dependency is only required when actually used, which is essential for optional dependencies. The caching prevents repeated require calls.

lib/xz/uncompress_stream.js (3)

9-18: Solid constructor implementation with proper error handling.

The constructor correctly sets up the decompressor and establishes error propagation. The error handling ensures that any issues in the decompression process are properly bubbled up to the consuming code.


21-39: Well-structured source type handling.

The implementation correctly handles different input types (file, buffer, stream) with consistent error propagation patterns. Each source type is properly handled with appropriate stream creation and piping.


42-45: Previous pipe event handler issues have been resolved.

The pipe event handler now correctly calls srcStream.unpipe(this) instead of the previously problematic srcStream.unpipe(srcStream). The implementation properly reroutes the source stream through the decompressor.

fengmk2 and others added 4 commits May 25, 2025 11:11
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
lib/xz/file_stream.js (1)

42-45: Pipe event handler is correctly implemented.

Good to see the previous critical bug has been addressed. The srcStream.unpipe(this) correctly unpipes the source from the current transform stream before piping to the compressor.

🧹 Nitpick comments (1)
lib/xz/file_stream.js (1)

1-1: Remove redundant 'use strict' directive.

Modern JavaScript modules are automatically in strict mode, making this directive unnecessary.

-'use strict';
🧰 Tools
🪛 Biome (1.9.4)

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee421a6 and b167355.

📒 Files selected for processing (3)
  • README.md (7 hunks)
  • lib/xz/file_stream.js (1 hunks)
  • test/xz/file_stream.test.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/xz/file_stream.test.js
  • README.md
🧰 Additional context used
🧬 Code Graph Analysis (1)
lib/xz/file_stream.js (3)
lib/xz/uncompress_stream.js (5)
  • fs (3-3)
  • require (7-7)
  • lzma (4-4)
  • utils (5-5)
  • streamifier (6-6)
test/xz/file_stream.test.js (1)
  • fs (1-1)
lib/xz/index.js (2)
  • utils (3-3)
  • XzFileStream (5-5)
🪛 Biome (1.9.4)
lib/xz/file_stream.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Node.js / Test (macos-latest, 20)
  • GitHub Check: Node.js / Test (windows-latest, 18)
🔇 Additional comments (2)
lib/xz/file_stream.js (2)

9-46: Excellent implementation with comprehensive source type handling.

The constructor properly handles different input source types (file, buffer, stream, and pipe) with appropriate error propagation. The pipe event handler has been correctly implemented to unpipe from this stream before redirecting to the compressor.


48-51: Proper Transform stream implementation.

The _transform method correctly delegates processing to the compressor stream by calling the callback immediately without processing chunks directly. This is the appropriate pattern when using an internal stream for actual data transformation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.xz support
1 participant