Gathering detailed insights and metrics for pako
Gathering detailed insights and metrics for pako
Gathering detailed insights and metrics for pako
Gathering detailed insights and metrics for pako
high speed zlib port to javascript, works in browser & node.js
npm install pako
99.5
Supply Chain
99.6
Quality
76
Maintenance
100
Vulnerability
99.6
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5,612 Stars
375 Commits
791 Forks
81 Watching
4 Branches
23 Contributors
Updated on 28 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-7.9%
5,094,036
Compared to previous day
Last week
2%
29,709,996
Compared to previous week
Last month
11%
122,356,749
Compared to previous month
Last year
11.9%
1,304,790,631
Compared to previous year
zlib port to javascript, very fast!
Why pako is cool:
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 v12.16.3 (zlib 1.2.9), 1mb input sample:
deflate-imaya x 4.75 ops/sec ±4.93% (15 runs sampled)
deflate-pako x 10.38 ops/sec ±0.37% (29 runs sampled)
deflate-zlib x 17.74 ops/sec ±0.77% (46 runs sampled)
gzip-pako x 8.86 ops/sec ±1.41% (29 runs sampled)
inflate-imaya x 107 ops/sec ±0.69% (77 runs sampled)
inflate-pako x 131 ops/sec ±1.74% (82 runs sampled)
inflate-zlib x 258 ops/sec ±0.66% (88 runs sampled)
ungzip-pako x 115 ops/sec ±1.92% (80 runs sampled)
node v14.15.0 (google's zlib), 1mb output sample:
deflate-imaya x 4.93 ops/sec ±3.09% (16 runs sampled)
deflate-pako x 10.22 ops/sec ±0.33% (29 runs sampled)
deflate-zlib x 18.48 ops/sec ±0.24% (48 runs sampled)
gzip-pako x 10.16 ops/sec ±0.25% (28 runs sampled)
inflate-imaya x 110 ops/sec ±0.41% (77 runs sampled)
inflate-pako x 134 ops/sec ±0.66% (83 runs sampled)
inflate-zlib x 402 ops/sec ±0.74% (87 runs sampled)
ungzip-pako x 113 ops/sec ±0.62% (80 runs sampled)
zlib's test is partially affected by marshalling (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:
npm install pako
Full docs - http://nodeca.github.io/pako/
1const pako = require('pako'); 2 3// Deflate 4// 5const input = new Uint8Array(); 6//... fill input data here 7const output = pako.deflate(input); 8 9// Inflate (simple wrapper can throw exception on broken stream) 10// 11const compressed = new Uint8Array(); 12//... fill data to uncompress here 13try { 14 const result = pako.inflate(compressed); 15 // ... continue processing 16} catch (err) { 17 console.log(err); 18} 19 20// 21// Alternate interface for chunking & without exceptions 22// 23 24const deflator = new pako.Deflate(); 25 26deflator.push(chunk1, false); 27deflator.push(chunk2); // second param is false by default. 28... 29deflator.push(chunk_last, true); // `true` says this chunk is last 30 31if (deflator.err) { 32 console.log(deflator.msg); 33} 34 35const output = deflator.result; 36 37 38const inflator = new pako.Inflate(); 39 40inflator.push(chunk1); 41inflator.push(chunk2); 42... 43inflator.push(chunk_last); // no second param because end is auto-detected 44 45if (inflator.err) { 46 console.log(inflator.msg); 47} 48 49const output = inflator.result;
Sometime you can wish to work with strings. For example, to send stringified objects to server. Pako's deflate detects input data type, and automatically recode strings to utf-8 prior to compress. Inflate has special option, to say compressed data has utf-8 encoding and should be recoded to javascript's utf-16.
1const pako = require('pako'); 2 3const test = { my: 'super', puper: [456, 567], awesome: 'pako' }; 4 5const compressed = pako.deflate(JSON.stringify(test)); 6 7const restored = JSON.parse(pako.inflate(compressed, { to: 'string' }));
Pako does not contain some specific zlib functions:
deflateCopy
, deflateBound
, deflateParams
,
deflatePending
, deflatePrime
, deflateTune
.inflateCopy
, inflateMark
,
inflatePrime
, inflateGetDictionary
, inflateSync
, inflateSyncPoint
, inflateUndermine
.Available as part of the Tidelift Subscription
The maintainers of pako and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
Personal thanks to:
Original implementation (in C):
/lib/zlib
folder/lib/zlib
contentNo vulnerabilities found.
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
project is fuzzed
Details
Reason
security policy file detected
Details
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More