Full refund within 14 days of purchase date.
This is an efficient asynchronous implementation of the Lempel-Ziv-Welch (LZW) compression algorithm in Javascript.
index.html).Minified library size is only ~4KB (~2KB when gzipped).
The index.html file included contains a testing form for the algorithm as well as automated tests based on predefined data which is good at catching boundary case errors.
To use the algorithm in your own projects include the lzw-async.js file using a script tag:
<script type="text/javascript" src="lzw-async.min.js"></script>
To compress call:
LZWAsync.compress(...)
To decompress call:
LZWAsync.decompress(...)
To use with node.js install the module:
$ npm install lzw-async
Note that when using it with node there is no LZWAsync namespace:
var lzw = require('lzw-async');
lzw.compress({
input : "test",
output : function(output) {
console.log(output);
}
});
There are two methods provided within the LZWAsync namespace:
compress
decompress
compress.Each method takes a single dictionary parameter which can contain the following entries:
input
output
function(result). This gets called with the resulting output
once the compression/decompression is finished.progress
function(percent). This gets called every a half second
with a progress update.dict
input. This may allow the
algorithm to initialize a smaller dictionary and thus enable better compression ratios.At the moment the compressor only accepts ASCII (upto 256) characters even though Javascript supports UTF-16 characters in its strings. For now, unless you can specify your required characters in the dict parameter, you should base64-encode your input prior to compression if it contains non-latin script. By base64 encoding you'll also be able to pass in a more limited dictionary character list and thereby gain greater compression ratios.
There are also dictionary optimisations which can be made to decrease the amount of memory used by the dictionary though speed will be impacted as a result.
The following resources where enormously helpful:
Developed by Ramesh Nair. Originally released July 2011.
Questions & Comments