JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 103
  • Score
    100M100P100Q88351F

node bindings for the xz compression library

Package Exports

  • xz

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 (xz) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

xz

Xz is the node binding for the xz library, which implements (streaming) LZMA2 compression.

LZMA2 is better than gzip & bzip2 in many cases. Read more about LZMA here: http://en.wikipedia.org/wiki/Lempel-Ziv-Markov_chain_algorithm

Install

$ npm install
$ npm run test

API

The API consists of only two stream transform classes: Compressor and Decompressor.

  • new xz.Compressor([preset], [options])
  • new xz.Decompressor([options])

The options object passed to node's Transform. Compression takes a "preset" number, which is an abstraction of the compression difficulty level, from 1 to 9, where 1 puts in the least effort. The default is 6.

Both objects are stream transforms that consume and produce Buffers. Here's example code to compress the sample file included with this distribution:

var fs = require("fs");
var xz = require("xz");

var compression = new xz.Compressor(9);
var inFile = fs.createReadStream("./testdata/minecraft.png");
var outFile = fs.createWriteStream("./testdata/minecraft.png.lzma2");

inFile.pipe(compression).pipe(outFile);

License

Apache 2 (open-source) license, included in 'LICENSE.txt'.

Authors