🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

node-liblzma

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-liblzma

Liblzma bindings for NodeJS

Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
900K
-12.48%
Maintainers
1
Weekly downloads
 
Created
Source

Node-libxz

An other way to deal with the XZ compression format with NodeJS !

What is XZ ?

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.

About this project

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:

  • lzma-purejs A pure JavaScript implementation of the algorithm
  • node-xz Node binding of XZ library
  • lzma-native A very complete implementation of XZ library bindings
  • Others are also available but they fork "xz" process in the background.

Installation

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

Usage

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.

Bugs

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..

License

This software is released under LGPL3.0+

Keywords

node

FAQs

Package last updated on 12 Oct 2014

Did you know?

Socket

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.

Install

Related posts