Pako is a high speed zlib port to JavaScript. Pako is primarily built on nodeJS but can also be browserified and used in browsers as single source file eliminating the dependency of nodeJS.
About: Pako is a high speed zlib port to JavaScript. It is almost as fast in modern JS engines as C implementation. Pako is primarily built on nodeJS but can also be browserified and used in browsers as single source file eliminating the dependency of nodeJS.
It also provides chunking support for big blobs. Some of the famous projects that use pako are browserify (via browserify-zlib), JSZip, mincer, JS-Git and Tedit by @creatronix
Installation:
node.js: npm install pako
browser: bower install pako
Sample code:
var pako = require('pako');
var input = new Uint8Array();
// fill input data here
var output = pako.deflate(input);
var compressed = new Uint8Array();
// fill data to uncompress here
try {
var result = pako.inflate(compressed);
} catch (err) {
console.log(err);
}
var inflator = new pako.Inflate();
inflator.push(chunk1, false);
inflator.push(chunk2, false);
inflator.push(chunkN, true);
if (inflator.err) {
console.log(inflator.msg);
}
var output = inflator.result;
Useful links: