🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

node-gzip

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-gzip

Simply gzip and ungzip in Node.js with promises

1.1.2
latest
Source
npm
Version published
Weekly downloads
122K
-17.7%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

node

FAQs

Package last updated on 24 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts