
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
node-liblzma
Advanced tools
An other way to deal with the XZ compression format with NodeJS !
XZ is a container for compressed archives. It can use LZMA1 or LZMA2 compression algorithms and is among the best compressors out there according to several benchmarks:
It has a good balance between compression time/ratio and decompression time/memory.
This project is close to node-xz or lzma-native as I have chosen to bind XZ library to NodeJS. But there are some differences:
Both download and deploy a specific liblzma version to be compiled from the sources. I did not want to rely on an embedded liblzma version and instead use the system one (most Linux distros have liblzma, if not look at INSTALL below) ;
It supports modes, presets (including "extreme"), all LZMA checks (CRC32/64, SHA-256 hash...), filters (X86,IA64,...) and should be even compatible with future extensions of liblzma as well ;
(Almost) complete NodeJS Zlib API / implementation compatibility so that switching from zlib/deflate to xz might be as easy as a string search/replace in your code editor :)
Also, as stated in src/liblzma/api/lzma/lzma12.h
"LZMA1 shouldn't be used for new applications unless you really know what you are doing. LZMA2 is almost always a better choice."
Therefore only LZMA2 is supported by this interface.
Thanks to the community, there are several choices out there:
You need to have the development package installed on your system. So you can either install it manually by downloading XZ SDK and build it, or if you have root access, you can do (e.g. if you have Debian based distro):
# apt-get install liblzma-dev
If you did install locally, set the include directory and library directory search paths as GCC environment variables.
$ export CPATH=$HOME/path/to/headers
$ export LIBRARY_PATH=$HOME/path/to/lib
$ export LD_LIBRARY_PATH=$HOME/path/to/lib:$LD_LIBRARY_PATH
The latest is needed for tests to be run right after.
Once done, a simple:
$ npm install
Will build and launch tests suite with Mocha.
If you want to try the unstable threading support, then opt in with
$ ENABLE_MT=1 npm install
As the API is very close to NodeJS Zlib, you will probably find a good reference there.
Otherwise examples can be found as part of the test suite, so feel free to use them! They are written in CoffeeScript.
If you find one, feel free to contribute as post a new issue! PR are accepted as well :)
If you compile with threads, you may see a bunch of warnings about -Wmissing-field-initializers.
This is normal and does not prevent threading from being active and working.
I did not yet figure how to fix this except by masking the warning..
This software is released under LGPL3.0+
FAQs
Native Node.js bindings for liblzma (XZ/LZMA2). Streaming, buffer and async APIs with browser support via WebAssembly. zlib-like API, TypeScript-first, prebuilt binaries for Linux/macOS/Windows.
The npm package node-liblzma receives a total of 728,216 weekly downloads. As such, node-liblzma popularity was classified as popular.
We found that node-liblzma demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.