# lzw-stream

> Streaming LZW decoder and encoder

Latest version **1.0.0** (published 2014-11-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install lzw-stream
pnpm add lzw-stream
yarn add lzw-stream
bun add lzw-stream
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2014-11-12 |
| First published | 2014-11-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Devon Govett |
| Maintainers | devongovett |
| Keywords | compression, lzw, stream |

## Links

- npm: https://www.npmjs.com/package/lzw-stream
- Repository: https://github.com/devongovett/lzw-stream
- Issues: https://github.com/devongovett/lzw-stream/issues
- npm.io page: https://npm.io/package/lzw-stream

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2014-11-12

## README

# lzw-stream

A streaming LZW encoder and decoder in JavaScript

## Usage

Install using npm:

    npm install lzw-stream

Pipe data to it:

```javascript
var LZWDecoder = require('lzw-stream/decoder');
var LZWEncoder = require('lzw-stream/encoder');
var fs = require('fs');

fs.createReadStream('in.txt')
  .pipe(new LZWEncoder)
  .pipe(new LZWDecoder)
  .pipe(fs.createWriteStream('out.txt'));
```

That example will produce a file `out.txt` that is identical to `in.txt`. Not very useful, 
but it illustrates how to use both the encoder and decoder. Check out the Node 
[stream docs](http://nodejs.org/api/stream.html) for more info on streams.

### dataSize

There is a `dataSize` option for both the encoder and decoder, passed in as an argument to
the constructor, which is the number of bits in each element of the input.  It is set to 
8 (or 1 byte) by default, since all elements in a buffer are 8 bits. If you knew you had
ASCII text, for example, you could set it to 7 since all ASCII characters can be represented
in 7 bits.  This would lead to better compression. On the other hand, if your elements are 
larger than 8 bits, then `dataSize` should be set to that size. Most of the time, however,
you should just use the default.

## Browser Usage

To use lzw-stream in the browser, check out [Browserify](http://browserify.org), which 
builds Node-style modules for browser usage.

## License

MIT

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