# iltorb

> Brotli compression/decompression with native bindings

Latest version **2.4.5** (published 2020-02-01) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install iltorb
pnpm add iltorb
yarn add iltorb
bun add iltorb
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.4.5 |
| Published | 2020-02-01 |
| First published | 2015-10-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/iltorb) |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 1.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 168 |
| Maintainers | mayhem, oohnoitz |
| Keywords | brotli, compression, decompression |

## Links

- npm: https://www.npmjs.com/package/iltorb
- Repository: https://github.com/nstepien/iltorb
- Issues: https://github.com/nstepien/iltorb/issues
- npm.io page: https://npm.io/package/iltorb

## Dependencies (5)

- [nan](https://npm.io/package/nan.md) ^2.14.0
- [npmlog](https://npm.io/package/npmlog.md) ^4.1.2
- [detect-libc](https://npm.io/package/detect-libc.md) ^1.0.3
- [which-pm-runs](https://npm.io/package/which-pm-runs.md) ^1.0.0
- [prebuild-install](https://npm.io/package/prebuild-install.md) ^5.3.3

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 2.4.5 (latest) — 2020-02-01
- 2.4.4 — 2019-10-25
- 2.4.3 — 2019-04-24
- 2.4.2 — 2019-03-11
- 2.4.1 — 2018-10-31
- 2.4.0 — 2018-07-31
- 2.3.2 — 2018-05-01
- 2.3.1 — 2018-04-30
- 2.3.0 — 2018-04-06
- 2.2.0 — 2018-03-30
- 2.1.0 — 2018-03-24
- 2.0.9 — 2018-03-23
- 2.0.8 — 2018-03-23
- 2.0.7 — 2018-03-23
- 2.0.6 — 2018-03-17
- … 31 more at https://npm.io/package/iltorb/versions

## README

# iltorb

[![NPM Version][npm-badge]][npm-url]
[![Travis Build Status][travis-badge]][travis-url]
[![AppVeyor Build Status][appveyor-badge]][appveyor-url]
[![CircleCI Build Status][circleci-badge]][circleci-url]

[iltorb](https://www.npmjs.com/package/iltorb) is a [Node.js](https://nodejs.org) package offering native bindings for the [brotli](https://github.com/google/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](https://github.com/nstepien/iltorb/releases) does not exist.

- Python 2.7
- GCC 4.8+ (Unix) or [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools) (Windows), see [Node Building tools](https://github.com/nodejs/node-gyp#installation).

## Methods

### Async

Omitting the callback argument will result in the compress and decompress methods to return a Promise.

#### compress(buffer[, brotliEncodeParams][, callback])

```javascript
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])

```javascript
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])

```javascript
const compressSync = require('iltorb').compressSync;

try {
  var output = compressSync(input);
} catch(err) {
  // ...
}
```

#### decompressSync(buffer)

```javascript
const decompressSync = require('iltorb').decompressSync;

try {
  var output = decompressSync(input);
} catch(err) {
  // ...
}
```

### Stream

#### compressStream([brotliEncodeParams])

```javascript
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()

```javascript
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:
- [type definition](https://github.com/google/brotli/blob/v1.0.4/c/enc/params.h#L30-L42)
- [defaults](https://github.com/google/brotli/blob/v1.0.4/c/enc/encode.c#L706-L720)
- [explanations](https://github.com/google/brotli/blob/v1.0.4/c/include/brotli/encode.h#L133-L205)

```javascript
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`


[npm-badge]: https://img.shields.io/npm/v/iltorb.svg
[npm-url]: https://www.npmjs.com/package/iltorb
[travis-badge]: https://img.shields.io/travis/nstepien/iltorb.svg
[travis-url]: https://travis-ci.org/nstepien/iltorb
[appveyor-badge]: https://ci.appveyor.com/api/projects/status/5x96vn5561bixics/branch/master?svg=true
[appveyor-url]: https://ci.appveyor.com/project/MayhemYDG/iltorb
[circleci-badge]: https://circleci.com/gh/nstepien/iltorb/tree/master.svg?style=shield
[circleci-url]: https://circleci.com/gh/nstepien/iltorb/tree/master

---
_Source: https://npm.io/package/iltorb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
