iltorb

Brotli compression/decompression with native bindings

The zlib module provides APIs for brotli compression/decompression starting with Node.js v10.16.0, please use it over iltorb
Last updated 6 years ago by mayhem .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install iltorb 
SYNC missed versions from official npm registry.

iltorb

NPM Version Travis Build Status AppVeyor Build Status CircleCI Build Status

iltorb is a Node.js package offering native bindings for the brotli compression library.

Install

This module uses prebuild to download a pre-compiled binary for your platform, if it exists. Otherwise, it will use node-gyp to build the module.

npm install iltorb

Prerequisites for Building

The following is required to build from source or when a pre-compiled binary does not exist.

Methods

Async

Omitting the callback argument will result in the compress and decompress methods to return a Promise.

compress(buffer[, brotliEncodeParams][, callback])

const compress = require('iltorb').compress;

// callback style
compress(input, function(err, output) {
  // ...
});

// promise style
compress(input)
  .then(output => /* ... */)
  .catch(err => /* ... */);

// async/await style
try {
  const output = await compress(input);
} catch(err) {
  // ...
}

decompress(buffer[, callback])

const decompress = require('iltorb').decompress;

// callback style
decompress(input, function(err, output) {
  // ...
});

// promise style
decompress(input)
  .then(output => /* ... */)
  .catch(err => /* ... */);

// async/await style
try {
  const output = await decompress(input);
} catch(err) {
  // ...
}

Sync

compressSync(buffer[, brotliEncodeParams])

const compressSync = require('iltorb').compressSync;

try {
  var output = compressSync(input);
} catch(err) {
  // ...
}

decompressSync(buffer)

const decompressSync = require('iltorb').decompressSync;

try {
  var output = decompressSync(input);
} catch(err) {
  // ...
}

Stream

compressStream([brotliEncodeParams])

const compressStream = require('iltorb').compressStream;
const fs = require('fs');

fs.createReadStream('path/to/input')
  .pipe(compressStream())
  .pipe(fs.createWriteStream('path/to/output'));
compressionStream.flush()

Call this method to flush pending data. Don't call this frivolously, premature flushes negatively impact the effectiveness of the compression algorithm.

decompressStream()

const decompressStream = require('iltorb').decompressStream;
const fs = require('fs');

fs.createReadStream('path/to/input')
  .pipe(decompressStream())
  .pipe(fs.createWriteStream('path/to/output'));

brotliEncodeParams

The compress, compressSync and compressStream methods may accept an optional brotliEncodeParams object to define some or all of brotli's compression parameters:

const brotliEncodeParams = {
  mode: 0,
  quality: 11,
  lgwin: 22,
  lgblock: 0,
  disable_literal_context_modeling: false,
  size_hint: 0, // automatically set for `compress` and `compressSync`
  large_window: false,
  npostfix: 0,
  ndirect: 0
};

Troubleshooting

  1. I am unable to install iltorb because the host (GitHub) that serves the binaries is blocked by my firewall.

    a) By default, if the binaries could not be downloaded for any reason, the install script will attempt to compile the binaries locally on your machine. This requires having all of the build requirements fulfilled.

    b) You can override the binary.host value found in package.json with the following methods:

    • using the following ENV variable npm_config_iltorb_binary_host=https://domain.tld/path
    • as an additional argument with npm install --iltorb_binary_host=https://domain.tld/path

    Note: Both of these would result in downloading the binary from https://domain.tld/path/vX.X.X/iltorb-vX.X.X-node-vXX-arch.tar.gz

Current Tags

  • 2.4.5                                ...           latest (5 years ago)

46 Versions

  • 2.4.5 [deprecated]           ...           5 years ago
  • 2.4.4 [deprecated]           ...           5 years ago
  • 2.4.3 [deprecated]           ...           6 years ago
  • 2.4.2 [deprecated]           ...           6 years ago
  • 2.4.1 [deprecated]           ...           6 years ago
  • 2.4.0 [deprecated]           ...           6 years ago
  • 2.3.2 [deprecated]           ...           7 years ago
  • 2.3.1 [deprecated]           ...           7 years ago
  • 2.3.0 [deprecated]           ...           7 years ago
  • 2.2.0 [deprecated]           ...           7 years ago
  • 2.1.0 [deprecated]           ...           7 years ago
  • 2.0.9 [deprecated]           ...           7 years ago
  • 2.0.8 [deprecated]           ...           7 years ago
  • 2.0.7 [deprecated]           ...           7 years ago
  • 2.0.6 [deprecated]           ...           7 years ago
  • 2.0.5 [deprecated]           ...           7 years ago
  • 2.0.4 [deprecated]           ...           7 years ago
  • 2.0.3 [deprecated]           ...           7 years ago
  • 2.0.2 [deprecated]           ...           7 years ago
  • 2.0.1 [deprecated]           ...           7 years ago
  • 2.0.0 [deprecated]           ...           7 years ago
  • 1.3.10 [deprecated]           ...           7 years ago
  • 1.3.9 [deprecated]           ...           7 years ago
  • 1.3.6 [deprecated]           ...           7 years ago
  • 1.3.5 [deprecated]           ...           7 years ago
  • 1.3.4 [deprecated]           ...           7 years ago
  • 1.3.3 [deprecated]           ...           7 years ago
  • 1.3.2 [deprecated]           ...           7 years ago
  • 1.3.1 [deprecated]           ...           8 years ago
  • 1.3.0 [deprecated]           ...           8 years ago
  • 1.2.1 [deprecated]           ...           8 years ago
  • 1.2.0 [deprecated]           ...           8 years ago
  • 1.1.0 [deprecated]           ...           8 years ago
  • 1.0.13 [deprecated]           ...           8 years ago
  • 1.0.12 [deprecated]           ...           8 years ago
  • 1.0.11 [deprecated]           ...           8 years ago
  • 1.0.9 [deprecated]           ...           9 years ago
  • 1.0.8 [deprecated]           ...           9 years ago
  • 1.0.7 [deprecated]           ...           9 years ago
  • 1.0.6 [deprecated]           ...           9 years ago
  • 1.0.5 [deprecated]           ...           9 years ago
  • 1.0.4 [deprecated]           ...           9 years ago
  • 1.0.3 [deprecated]           ...           9 years ago
  • 1.0.2 [deprecated]           ...           9 years ago
  • 1.0.1 [deprecated]           ...           9 years ago
  • 1.0.0 [deprecated]           ...           9 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 10
Last Day 0
Last Week 10
Last Month 0
Dependencies (4)
Dev Dependencies (7)

Copyright 2013 - present © cnpmjs.org | Home |