Package Exports
- pako
- pako/dist/pako.min
- pako/dist/pako_deflate
- pako/dist/pako_inflate
- pako/dist/pako_inflate.min
- pako/dist/pako_inflate.min.js
- pako/lib/deflate
- pako/lib/deflate.js
- pako/lib/inflate
- pako/lib/inflate.js
- pako/lib/zlib/adler32
- pako/lib/zlib/constants
- pako/lib/zlib/crc32
- pako/lib/zlib/deflate
- pako/lib/zlib/deflate.js
- pako/lib/zlib/inflate
- pako/lib/zlib/inflate.js
- pako/lib/zlib/messages
- pako/lib/zlib/messages.js
- pako/lib/zlib/zstream
- pako/lib/zlib/zstream.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pako) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
pako - zlib port to javascript, very fast!
Why pako is cool:
- Almost as fast in modern JS engines as C implementation (see benchmarks).
- Works in browsers, you can browserify any separate component.
- Both Sync & streamable (for big blobs) interfaces.
- It's fresh - ports the latest zlib version (now 1.2.8), results are binary equal.
This project was done to understand how fast JS can be and is it necessary to develop native C modules for CPU-intensive tasks. Enjoy the result!
Benchmarks:
node v0.10.26, 1mb sample:
deflate-dankogai x 4.74 ops/sec ±0.68% (15 runs sampled)
deflate-gildas x 4.61 ops/sec ±1.73% (15 runs sampled)
deflate-imaya x 3.10 ops/sec ±3.73% (11 runs sampled)
! deflate-pako x 7.11 ops/sec ±0.26% (21 runs sampled)
deflate-pako-untyped x 4.34 ops/sec ±1.35% (14 runs sampled)
deflate-zlib x 14.34 ops/sec ±2.90% (68 runs sampled)
inflate-dankogai x 31.29 ops/sec ±0.72% (56 runs sampled)
inflate-imaya x 30.49 ops/sec ±0.84% (53 runs sampled)
! inflate-pako x 70.00 ops/sec ±1.60% (71 runs sampled)
inflate-pako-untyped x 17.67 ops/sec ±1.27% (33 runs sampled)
inflate-zlib x 70.82 ops/sec ±1.69% (81 runs sampled)
node v0.11.11, 1mb sample:
deflate-dankogai x 5.61 ops/sec ±0.30% (17 runs sampled)
deflate-gildas x 4.97 ops/sec ±5.68% (16 runs sampled)
deflate-imaya x 3.53 ops/sec ±4.19% (12 runs sampled)
! deflate-pako x 11.52 ops/sec ±0.23% (32 runs sampled)
deflate-pako-untyped x 5.12 ops/sec ±1.44% (17 runs sampled)
deflate-zlib x 14.33 ops/sec ±3.34% (63 runs sampled)
inflate-dankogai x 42.96 ops/sec ±0.19% (57 runs sampled)
inflate-imaya x 85.05 ops/sec ±1.07% (71 runs sampled)
! inflate-pako x 97.58 ops/sec ±0.69% (80 runs sampled)
inflate-pako-untyped x 18.06 ops/sec ±0.65% (56 runs sampled)
inflate-zlib x 60.60 ops/sec ±2.04% (67 runs sampled)zlib's test is partialy afferted by marshling (that make sense for inflate only). You can change deflate level to 0 in benchmark source, to investigate details. For deflate level 6 results can be considered as correct.
Install:
node.js:
npm install pakobrowser:
bower install pakoExample & API
Full docs - http://nodeca.github.io/pako/
var pako = require('pako');
// Deflate
//
var input = new Uint8Array();
//... fill input data here
var output = pako.deflate(input);
// Inflate (simple wrapper can throw exception on broken stream)
//
var compressed = new Uint8Array();
//... fill data to uncompress here
try {
var result = pako.inflate(compressed);
catch (err) {
console.log(err);
}
//
// Alternate interface for chunking & without exceptions
//
var inflator = new pako.Inflate();
inflator.push(chunk1, false);
inflator.push(chunk2, false);
...
inflator.push(chunkN, true); // true -> last chunk
if (inflator.err) {
console.log(inflator.msg);
}
var output = inflator.result;
Notes
Pako does not contain some specific zlib functions:
- deflate - writing custom gzip headers and methods
deflateSetDictionary,deflateParams,deflateSetHeader,deflateBound,deflatePending. - inflate - getting custom gzip headers and methods
inflateGetDictionary,inflateGetHeader,inflateSetDictionary,inflateSync,inflateSyncPoint,inflateCopy,inflateUndermine,inflateMark.
Authors
Personal thanks to Vyacheslav Egorov (@mraleph) for his awesome tutoruals about optimising JS code for v8, IRHydra tool and his advices.
License
MIT
