node-gzip

Simply gzip and ungzip in Node.js with promises

node-gzip downloads node-gzip version node-gzip license

node-gzip类似的npm包:

npm下载趋势

3 年
🌟 在 node-gzip 的 README.md 中显示实时使用量图表,只需复制下面的代码。
## Usage Trend
[![Usage Trend of node-gzip](https://npm-compare.com/img/npm-trend/THREE_YEARS/node-gzip.png)](https://npm-compare.com/node-gzip#timeRange=THREE_YEARS)

Cumulative GitHub Star Trend

🌟 在 node-gzip 的 README.md 中显示 GitHub stars 趋势图表,只需复制下面的代码。
## GitHub Stars Trend
[![GitHub Stars Trend of node-gzip](https://npm-compare.com/img/github-trend/node-gzip.png)](https://npm-compare.com/node-gzip)

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
node-gzip055-18 年前MIT

node-gzip的README

node-gzip

Gzip and ungzip in Node.js

Tiny and easy to use wrapper around zlib.gzip and zlib.gunzip to support promises.

const compressed = await gzip('Hello World');

Install

npm install node-gzip --save

Examples

With Promises

const {gzip, ungzip} = require('node-gzip');

gzip('Hello World')
  .then((compressed) => {
    return ungzip(compressed);
  })
  .then((decompressed) => {
    console.log(decompressed.toString());     //Hello World
  });

With async / await

const {gzip, ungzip} = require('node-gzip');

const compressed = await gzip('Hello World');

const decompressed = await ungzip(compressed);

console.log(decompressed.toString());        //Hello World

Options

Pass options just like with Zlib. See all options.

await gzip('Hello World', {...});

Description

gzip(input[,options])

  • input: Buffer | TypedArray | DataView | ArrayBuffer | string
  • returns: Buffer

ungzip(input[,options])

  • input: Buffer | TypedArray | DataView | ArrayBuffer | string
  • returns: Buffer

Use toString() after ungzip to convert the Buffer into a string.

Supports Node.js version 0.12 and higher.


License

node-gzip is MIT licensed.