Package Exports
- lzma-native
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (lzma-native) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
lzma-native
Provides bindings to the native liblzma library
Example usage:
The simplest possible usage:
var lzma = require('lzma-native');
var encoder = lzma.createStream();
process.stdin.pipe(encoder).pipe(process.stdout);This mimicks the functionality of the xz command line util.
Equivalently, one could have written
var encoder = lzma.createStream('easyEncoder', {preset: lzma.PRESET_DEFAULT, check: lzma.CHECK_CRC32})or, for stronger and slower compression:
var encoder = lzma.createStream('easyEncoder', {preset: 9})Here easyEncoder corresponds to the xz command line util, resp. its file format .xz.
For the older .lzma format, you can just use aloneEncoder instead.
The API is loosely based on the native API, with a few bits of wrapper code added for convenience.
Methods like stream.code and lzma.crc32 accept Node.js Buffers as arguments.
Unless you set .synchronous = true in createStreams second parameter, the library will use its
own thread for compression (if compiled with support for that).
The encoder object here is an instance of stream.Duplex (see the Node.js docs),
so you could also manually perform any of the write and read operations that you’re familiar with on it.
List of encoders/decoders and options
Encoders and decoders you probably are interested in:
easyEncoder: Creates.xzfiles. Supports.presetand.checkoptions.aloneEncoder: Creates.lzmafiles. Supports.presetand a bunch of very specific options (see the liblzma C headers for details)autoDecoder: Supports various flags. Detects input type automatically.
That is, the following is essentially (quite a slow version of) cat:
var encoder = lzma.createStream('easyEncoder');
var decoder = lzma.createStream('autoDecoder');
process.stdin.pipe(encoder).pipe(decoder).pipe(process.stdout);If you know specifically what you want, you may also look into these encoders:
rawDecoder: Supports.filters.rawEncoder: Supports.filters.streamEncoder: Supports.filtersand.check.streamDecoder: Supports various flags.aloneDecoder: Supports various flags.
Also, all encoders accept a .memlimit option.
Installation
This package requires that you have the corresponding C library installed,
e. g. via sudo apt-get install liblzma-dev or your equivalent of that.
You can also download the source from the original author.
Once you have the library, npm install lzma-native will do.
You may also need a somewhat recent C++ compiler, and asynchronous
compression support requires std::thread, which is included in C++11
(but is not essential for compiling).