pako
==========================================
[![Build Status](https://travis-ci.org/nodeca/pako.svg?branch=master)](https://travis-ci.org/nodeca/pako)
[![NPM version](https://img.shields.io/npm/v/pako.svg)](https://www.npmjs.org/package/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.
- Chunking support for big blobs.
- Results are binary equal to well known [zlib](http://www.zlib.net/) (now contains ported zlib v1.2.8).
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!
__Famous projects, using pako:__
- [browserify](http://browserify.org/) (via [browserify-zlib](https://github.com/devongovett/browserify-zlib))
- [JSZip](http://stuk.github.io/jszip/)
- [mincer](https://github.com/nodeca/mincer)
- [JS-Git](https://github.com/creationix/js-git) and
[Tedit](https://chrome.google.com/webstore/detail/tedit-development-environ/ooekdijbnbbjdfjocaiflnjgoohnblgf)
by [@creationix](https://github.com/creationix)
__Benchmarks:__
```
node v0.10.26, 1mb sample:
deflate-dankogai x 4.73 ops/sec ±0.82% (15 runs sampled)
deflate-gildas x 4.58 ops/sec ±2.33% (15 runs sampled)
deflate-imaya x 3.22 ops/sec ±3.95% (12 runs sampled)
! deflate-pako x 6.99 ops/sec ±0.51% (21 runs sampled)
deflate-pako-string x 5.89 ops/sec ±0.77% (18 runs sampled)
deflate-pako-untyped x 4.39 ops/sec ±1.58% (14 runs sampled)
* deflate-zlib x 14.71 ops/sec ±4.23% (59 runs sampled)
inflate-dankogai x 32.16 ops/sec ±0.13% (56 runs sampled)
inflate-imaya x 30.35 ops/sec ±0.92% (53 runs sampled)
! inflate-pako x 69.89 ops/sec ±1.46% (71 runs sampled)
inflate-pako-string x 19.22 ops/sec ±1.86% (49 runs sampled)
inflate-pako-untyped x 17.19 ops/sec ±0.85% (32 runs sampled)
* inflate-zlib x 70.03 ops/sec ±1.64% (81 runs sampled)
node v0.11.12, 1mb sample:
deflate-dankogai x 5.60 ops/sec ±0.49% (17 runs sampled)
deflate-gildas x 5.06 ops/sec ±6.00% (16 runs sampled)
deflate-imaya x 3.52 ops/sec ±3.71% (13 runs sampled)
! deflate-pako x 11.52 ops/sec ±0.22% (32 runs sampled)
deflate-pako-string x 9.53 ops/sec ±1.12% (27 runs sampled)
deflate-pako-untyped x 5.44 ops/sec ±0.72% (17 runs sampled)
* deflate-zlib x 14.05 ops/sec ±3.34% (63 runs sampled)
inflate-dankogai x 42.19 ops/sec ±0.09% (56 runs sampled)
inflate-imaya x 79.68 ops/sec ±1.07% (68 runs sampled)
! inflate-pako x 97.52 ops/sec ±0.83% (80 runs sampled)
inflate-pako-string x 45.19 ops/sec ±1.69% (57 runs sampled)
inflate-pako-untyped x 24.35 ops/sec ±2.59% (40 runs sampled)
* inflate-zlib x 60.32 ops/sec ±1.36% (69 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:__
node.js:
```
npm install pako
```
browser:
```
bower install pako
```
Example & API
-------------
Full docs - http://nodeca.github.io/pako/
```javascript
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;
```
Sometime you can wish to work with strings. For example, to send
big objects as json to server. Pako detects input data type. You can
force output to be string with option `{ to: 'string' }`.
```javascript
var pako = require('pako');
var test = { my: 'super', puper: [456, 567], awesome: 'pako' };
var binaryString = pako.deflate(JSON.stringify(test), { to: 'string' });
//
// Here you can do base64 encode, make xhr requests and so on.
//
var restored = JSON.parse(pako.inflate(binaryString, { to: 'string' }));
```
Notes
-----
Pako does not contain some specific zlib functions:
- __deflate__ - methods `deflateCopy`, `deflateBound`, `deflateParams`,
`deflatePending`, `deflatePrime`, `deflateTune`.
- __inflate__ - methods `inflateCopy`, `inflateMark`,
`inflatePrime`, `inflateGetDictionary`, `inflateSync`, `inflateSyncPoint`, `inflateUndermine`.
- High level inflate/deflate wrappers (classes) may not support some flush
modes. Those should work: Z_NO_FLUSH, Z_FINISH, Z_SYNC_FLUSH.
pako for enterprise
-------------------
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.](https://tidelift.com/subscription/pkg/npm-pako?utm_source=npm-pako&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
Authors
-------
- Andrey Tupitsin [@anrd83](https://github.com/andr83)
- Vitaly Puzrin [@puzrin](https://github.com/puzrin)
Personal thanks to:
- Vyacheslav Egorov ([@mraleph](https://github.com/mraleph)) for his awesome
tutorials about optimising JS code for v8, [IRHydra](http://mrale.ph/irhydra/)
tool and his advices.
- David Duponchel ([@dduponchel](https://github.com/dduponchel)) for help with
testing.
Original implementation (in C):
- [zlib](http://zlib.net/) by Jean-loup Gailly and Mark Adler.
License
-------
- MIT - all files, except `/lib/zlib` folder
- ZLIB - `/lib/zlib` content
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
qrcode.rar (70个子文件)
qrcode
index
index.js 892B
index.json 27B
index.wxss 92B
index.wxml 249B
package.json 277B
node_modules
jsqr
package.json 1KB
LICENSE 11KB
dist
binarizer
index.d.ts 271B
locator
index.d.ts 312B
jsQR.js 251KB
BitMatrix.d.ts 395B
index.d.ts 762B
decoder
decodeData
shiftJISTable.d.ts 68B
BitStream.d.ts 208B
index.d.ts 634B
version.d.ts 351B
reedsolomon
GenericGF.d.ts 582B
GenericGFPoly.d.ts 545B
index.d.ts 82B
decoder.d.ts 146B
extractor
index.d.ts 278B
README.md 5KB
.package-lock.json 919B
pako
index.js 347B
package.json 1KB
LICENSE 1KB
dist
pako_inflate.min.js 22KB
pako.js 216KB
pako_deflate.min.js 27KB
pako_inflate.js 106KB
pako.min.js 45KB
pako_deflate.js 125KB
CHANGELOG.md 4KB
lib
deflate.js 11KB
inflate.js 12KB
utils
strings.js 5KB
common.js 2KB
zlib
zstream.js 2KB
messages.js 2KB
deflate.js 60KB
gzheader.js 2KB
inftrees.js 12KB
inflate.js 49KB
README 2KB
adler32.js 2KB
crc32.js 2KB
inffast.js 12KB
constants.js 2KB
trees.js 39KB
README.md 6KB
upng-js
package.json 577B
LICENSE 1KB
UPNG.js 31KB
README.md 3KB
app.json 313B
package-lock.json 2KB
imgs
hello+world.png 2KB
sunrise.webp 20KB
.eslintrc.js 587B
project.private.config.json 282B
sitemap.json 191B
app.wxss 0B
app.js 29B
project.config.json 1KB
miniprogram_npm
jsqr
index.js 252KB
index.js.map 310KB
pako
index.js 218KB
index.js.map 259KB
upng-js
index.js 32KB
index.js.map 37KB
共 70 条
- 1
前端御书房
- 粉丝: 8256
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0