Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Rebsos/node-gzip
Simply gzip and ungzip in Node.js with promises
https://github.com/Rebsos/node-gzip
Last synced: 2 months ago
JSON representation
Simply gzip and ungzip in Node.js with promises
- Host: GitHub
- URL: https://github.com/Rebsos/node-gzip
- Owner: Rebsos
- License: mit
- Created: 2018-04-20T21:52:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-24T12:09:19.000Z (over 6 years ago)
- Last Synced: 2024-11-03T07:04:14.967Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 54
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - node-gzip
README
# node-gzip
> Gzip and ungzip in Node.jsTiny and easy to use wrapper around [zlib.gzip](https://nodejs.org/api/zlib.html#zlib_zlib_gzip_buffer_options_callback) and [zlib.gunzip](https://nodejs.org/api/zlib.html#zlib_zlib_gunzip_buffer_options_callback) to support promises.
```js
const compressed = await gzip('Hello World');
```## Install
```sh
npm install node-gzip --save
```## Examples
#### With Promises
```js
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
```js
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](https://nodejs.org/api/zlib.html). See all [options](https://nodejs.org/api/zlib.html#zlib_class_options).
```js
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](./LICENSE).