Package Exports
- iltorb
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 (iltorb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
iltorb
iltorb is a Node.js package offering native bindings for the brotli compression library.
Install
This module uses node-pre-gyp to download a pre-compiled binary for your platform, if it exists. Otherwise, it will use node-gyp to build the module.
npm install iltorbPrerequisites for Building
The following is required to build from source or when a pre-compiled binary does not exist.
- Python 2.7
- GCC 4.8+ (Unix) or windows-build-tools (Windows), see Node Building tools.
Methods
Async
compress(buffer[, brotliEncodeParams], callback)
const compress = require('iltorb').compress;
compress(input, function(err, output) {
// ...
});decompress(buffer[, brotliDecodeParams], callback)
const decompress = require('iltorb').decompress;
decompress(input, function(err, output) {
// ...
});Sync
compressSync(buffer[, brotliEncodeParams])
const compressSync = require('iltorb').compressSync;
try {
var output = compressSync(input);
} catch(err) {
// ...
}decompressSync(buffer[, brotliDecodeParams])
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([brotliDecodeParams])
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,
size_hint: 0, // automatically set for `compress` and `compressSync`
disable_literal_context_modeling: false,
dictionary: Buffer
};brotliDecodeParams
The decompress, decompressSync and decompressStream methods may accept an optional brotliDecodeParams object to provide a custom dictionary.
const brotliDecodeParams = {
dictionary: Buffer
};Troubleshooting
I am unable to install
iltorbbecause 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,
npmwill attempt to compile the binaries locally on your machine. This requires having all of the build requirements fulfilled.b) You can override the
binary.hostvalue found inpackage.jsonwith the following methods:- using the following ENV variable
npm_config_iltorb_binary_host_mirror=url - as an additional argument with npm install
--iltorb_binary_host_mirror=url
- using the following ENV variable