About

Lempel–Ziv–Welch (LZW) is a universal lossless data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch. It was published by Welch in 1984 as an improved implementation of the LZ78 algorithm published by Lempel and Ziv in 1978.

lzwFloss is a multithreaded javascript implementation using the Hamsters.js multithreading library.

Since processing happens in the background on the client in a non blocking fashion you can use this to compress any data going back and forth through typical xhr request while still providing a seamless user experience, also effective for compressing data for session & local storage.

Getting Started

Obtain a copy of the library by using one of the options below,

Node.js

Install the library by running npm install lzwfloss.js Require the library into your app.js file

var lzwFloss = require ( " lzwfloss.js " ) ;

Ensure you have also required and initiated Hamsters.js as well like so

var hamsters = require ( ' hamsters.js ' ) ; hamsters . init ( ) ;

HTML

Head over to the read me page for Hamsters.js and follow the instructions to add the library to your project Download a copy of the latest lzwFloss release version, or clone the repo locally Upload the lzwFloss.js library file to your server and add the script to your project as described below

< script type = " text/javascript " src = " path/to/lzwFloss.js " > HTML5 < script src = " path/to/lzwFloss.js " > </ script >

Usage

Encode a string on a background thread

lzwFloss . encode ( stringToEncode , function ( encodedString ) { } ) ;

Decode an already encoded string on a background thread

lzwFloss . decode ( stringToDecode , function ( decodedString ) { } ) ;

Demo

You can find a jsfiddle demo example here demonstrating text encoding and decoding using Hamsters.js using a single background thread for encoding and decoding.