Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

iltorb

nstepien347.8kMITdeprecated2.4.5TypeScript support: definitely-typed

The zlib module provides APIs for brotli compression/decompression starting with Node.js v10.16.0, please use it over iltorb

Brotli compression/decompression with native bindings

brotli, compression, decompression

readme

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

changelog

Change Log

All notable changes to this project will be documented in this file. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

2.4.5 - 2020-02-01

  • iltorb is now deprecated in favor of zlib.
    • The zlib module has support for brotli compression/decompression APIs starting with Node.js v10.16.0.

2.4.4 - 2019-10-25

Added

  • Support for Node 13

Removed

  • Dropped support for Node 6 and Node 11

2.4.3 - 2019-04-24

Added

  • Support for Node 12

Changed

  • Updated npm dependencies.

2.4.2 - 2019-03-11

Changed

  • Moved back to using NAN from N-API to hopefully fix some segmentation faults.

2.4.1 - 2018-10-31

Added

  • Support for Node 11

Fixed

  • Fixed Module did not self-register errors, happening when require()-ing iltorb multiple times, with worker threads for example. #78

Changed

2.4.0 - 2018-07-31

Changed

  • Updated brotli from v1.0.4 to v1.0.5
  • Replaced NAN with N-API

Removed

  • Dropped support for Node 9

2.3.2 - 2018-05-01

Fixed

  • Fixed pre-compiled binaries download script

2.3.1 - 2018-04-30

Added

  • Support for Node 10

Removed

  • Dropped support for Node 4

2.3.0 - 2018-04-06

Added

  • The compress and decompress methods will now return a promise when the callback argument is missing.
    • This change enables using those methods in async/await flow.

2.2.0 - 2018-03-30

Changed

Added

  • Support for new brotli compression parameters:
    • large_window
    • npostfix
    • ndirect

Fixed

  • brotli parameter size_hint was being parsed as a boolean instead of an integer.

2.1.0 - 2018-03-24

Changed

  • Reduced package size by ~9M

Removed

  • Use bundled node-gyp provided by package managers instead

2.0.9 - 2018-03-23

Fixed

  • Build dependencies were incorrectly fixed

2.0.8 - 2018-03-23

Fixed

  • Missing dependency was added back

2.0.7 - 2018-03-23

Fixed

  • Install process on non-npm package managers

2.0.6 - 2018-03-16

Added

  • Support for --no-bin-link

Changed

  • Moved build.js to scripts directory

2.0.5 - 2018-03-12

Removed

  • Workaround for --no-bin-link

2.0.4 - 2018-03-11

Changed

Fixed

  • Fixed installation with --no-bin-links

2.0.3 - 2017-12-02

Changed

2.0.2 - 2017-10-24

Fixed

  • Link failure on Android

2.0.1 - 2017-10-16

Added

  • Added CircleCI status badge to README
  • Support Linux distributions both glibc and musql systems with pre-compiled binaries for both

Changed

  • Replace Travis-CI with CircleCI for Linux platforms

2.0.0 - 2017-10-12

Changed

Removed

  • Removed custom dictionary support

1.3.10 - 2017-10-10

Fixed

  • Revert package.json change which removed the binary key containing remote path and host

1.3.9 - 2017-10-09

Fixed

  • Revert package.json change which removed the binary key containing module name and path
  • Update CI to build all supported versions
  • Update Appyveyor to properly upload binaries

1.3.8 - 2017-10-08

Removed

  • README no longer contains a TROUBLESHOOT section

1.3.7 - 2017-10-08

Changed

  • Replaced node-pre-gyp with prebuild
  • Update build pipeline to output single binary

1.3.6 - 2017-08-30

Changed

  • Removed workaround for distros with old libc versions

Fixed

  • Infinite compression loop

Removed

  • Drop support for Node 7

1.3.5 - 2017-07-18

Changed

  • Update CI build pipeline to publish to GitHub instead of S3

1.3.4 - 2017-07-09

Fixed

  • Link failure on ARM

1.3.3 - 2017-07-04

Fixed

  • Link failure on ARM

1.3.2 - 2017-07-01

Changed

  • Support Linux distributions with older glibc versions via memcpy patch

1.3.1 - 2017-05-31

Changed

  • Published pre-compiled binaries for Node 8

1.3.0 - 2017-05-14

Added

  • CHANGELOG
  • Support size_hint and disable_literal_context_modeling encode parameters
  • Support for Windows x86

Changed

  • Update CI build configs to use JOBS=max
  • Update Brotli dependency to brotli-0.6.0

1.2.1 - 2017-04-12

Added

  • README contains link to pre-compiled binaries and information on building prerequisites

Changed

  • Update CI to publish on tags only

1.2.0 - 2017-04-11

Added

  • Support for the flush() method on compression streams

1.1.0 - 2017-04-09

Added

  • Support for pre-built binaries on supported platforms
  • Support for custom directory with decoder

Changed

  • Update CI build matrix to test with Node v7.x
  • Update link to Brotli compression settings
  • Update NPM dependencies: nan to 2.6.1
  • Update syntax to ES2015
  • Replace expect.js with chai

Removed

  • Drop support for Node v0.10, Node v0.12, and Node v5.x
  • Drop support for Windows x86

1.0.13 - 2016-10-08

Added

  • README contains information about windows build tools

Changed

1.0.12 - 2016-06-18

Changed

  • Increase decode output buffer size to improve decoding performance

1.0.11 - 2016-06-17

Fixed

  • Add missing brotli/common files to package

1.0.10 - 2016-06-17

Changed

  • Increase timeout for tests that work with large input buffers
  • Update Brotli dependency to brotli-0.5.0
  • Update CI build matrix to test with Node v6.x

1.0.9 - 2016-02-09

Added

  • Support for Windows

Changed

  • Update link to Brotli compression settings
  • Update Brotli dependency to brotli-0.3.0

1.0.8 - 2016-01-31

Changed

  • Update Travis CI build matrix to test with Node v0.10

Removed

  • constructor.Reset() calls in destructors

1.0.7 - 2015-11-04

Added

  • DecodeWorker, StreamDecode, StreamDecodeWorker destructor
  • EncodeWorker, StreamEncodeWorker destructor
  • constructor.Reset() calls in destructors

Changed

  • Update constructors to use most up-to-date NAN ObjectWrap

1.0.6 - 2015-11-03

Added

  • StreamEncode destructor

Changed

  • Update Travis CI build matrix to test with Node v5.x

1.0.5 - 2015-10-27

Added

  • Support for older implementation of streams

Changed

  • Downgrade to ES5
  • Update Travis CI build matrix to test with Node v0.12
  • Update Brotli dependency to brotli@8523d36

1.0.4 - 2015-10-24

Added

  • Unbuffered streaming decompression
  • Test for compression parameters with streams

Changed

  • Restructure encoder/decoder code into their own subdirectories
  • Move BufferOut, EncoderWorker, DecodeWorker and brotli buffer output functions into their own files
  • Update cflags to ignore -Wsign-compare warnings
  • Update Brotli dependency to brotli@87281b1

1.0.3 - 2015-10-19

Added

  • Unbuffered streaming compression

1.0.2 - 2015-10-19

Changed

Fixed

  • Handle large input buffers properly

1.0.1 - 2015-10-19

Added

  • README now contains badges to NPM and Travis CI

Fixed

  • Fix transform streams to properly handle empty input
  • Update Travis CI configuration file to properly compile

[1.0.0] - 2015-10-18