Simply gzip and ungzip in Node.js with promises
npm install node-gzipjs
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. See all 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.