Package Exports
- node-gzip
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-gzip) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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.