Socket
Socket
Sign inDemoInstall

lzw-stream

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lzw-stream

Streaming LZW decoder and encoder


Version published
Weekly downloads
12
decreased by-7.69%
Maintainers
1
Install size
6.20 MB
Created
Weekly downloads
 

Readme

Source

lzw-stream

A streaming LZW encoder and decoder in JavaScript

Usage

Install using npm:

npm install lzw-stream

Pipe data to it:

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 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, which builds Node-style modules for browser usage.

License

MIT

Keywords

FAQs

Last updated on 12 Nov 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc