feat: add XZ compression and decompression support
This PR adds XZ compression and decompression support to the compressing library, addressing issue #96. Added XZ compression module with FileStream and UncompressStream classes, implemented compressFile() and uncompress() functions, added TypeScript definitions, and comprehensive unit tests. Fixes #96
Code with TRAE SOLO.
Summary by CodeRabbit
-
New Features
- Added xz compression support with xz.compressFile, xz.uncompress, xz.decompress and streaming APIs xz.FileStream and xz.UncompressStream (supporting file paths, Buffers, and Streams; options include preset/threads).
-
Tests
- Added comprehensive tests for xz APIs and streams, covering multiple input/output forms, error propagation, and cross-platform content checks.
-
Chores
- Added lzma-native dependency to enable xz functionality.
[!NOTE]
Other AI code review bot(s) detected
CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.
Walkthrough
Adds an xz namespace and implementation: typings, index export, lib/xz implementation (FileStream, UncompressStream, helpers), lzma-native dependency, and tests for xz compression/decompression across file/buffer/stream sources.
Changes
| Cohort / File(s) | Summary of changes |
|---|---|
Typings: xz namespaceindex.d.ts |
Added export namespace xz with compressFile, uncompress, decompress and stream classes FileStream, UncompressStream typings. |
Root exportindex.js |
Exposed xz via exports.xz = require('./lib/xz'). |
XZ implementationlib/xz/*lib/xz/index.js, lib/xz/file_stream.js, lib/xz/uncompress_stream.js |
Implemented XZ module: FileStream (extends lzma.Compressor) and UncompressStream (extends lzma.Decompressor); handle sources (file, buffer, stream); exported helpers compressFile, uncompress, decompress via utils.makeFileProcessFn. |
Dependencypackage.json |
Added dependency lzma-native: ^8.0.6. |
Tests: xztest/xz/*test/xz/index.test.js, test/xz/file_stream.test.js, test/xz/uncompress_stream.test.js |
Added tests covering xz FileStream/UncompressStream and helpers for file/buffer/stream inputs, content checks, and error propagation. |
Sequence Diagram(s)
sequenceDiagram
actor Caller
participant xz as xz (lib/xz)
participant utils
participant FS as FileStream
participant lzma as lzma-native
Caller->>xz: compressFile(source, dest, opts)
xz->>utils: makeFileProcessFn(FileStream)
utils-->>xz: wrapper fn
Caller->>FS: new FileStream(opts)
FS->>lzma: instantiate Compressor
FS->>FS: detect source (file|buffer|stream) and pipe into compressor
lzma-->>Caller: compressed data to dest
sequenceDiagram
actor Caller
participant xz as xz (lib/xz)
participant utils
participant US as UncompressStream
participant lzma as lzma-native
Caller->>xz: uncompress(source, dest, opts)
xz->>utils: makeFileProcessFn(UncompressStream)
utils-->>xz: wrapper fn
Caller->>US: new UncompressStream(opts)
US->>lzma: instantiate Decompressor
US->>US: detect source (file|buffer|stream) and pipe into decompressor
lzma-->>Caller: decompressed data to dest
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| .xz support (#96) | ✅ |
Suggested reviewers
- MichaelDeBoey
Poem
"I nibble bytes and tuck them tight,
A carrot-shaped archive out of sight.
With lzma hum and streamy cheer,
I squash and swell — then reappear.
Hop, hop, .xz is here!"
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
feat/xz-compression-support
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.
🪧 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.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- 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.
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
| Diff | Package | Supply Chain Security |
Vulnerability | Quality | Maintenance | License |
|---|---|---|---|---|---|---|
| lzma-native@8.0.6 |
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 98.15%. Comparing base (ba52b7b) to head (bd31c50).
:warning: Report is 1 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #115 +/- ##
==========================================
+ Coverage 97.99% 98.15% +0.16%
==========================================
Files 19 22 +3
Lines 1048 1140 +92
Branches 277 301 +24
==========================================
+ Hits 1027 1119 +92
Misses 21 21
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.