Socket
Socket
Sign inDemoInstall

zlib

Package Overview
Dependencies
0
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    zlib

Simple, synchronous deflate/inflate for buffers


Version published
Weekly downloads
330K
decreased by-5.64%
Maintainers
5
Created
Weekly downloads
 

Package description

What is zlib?

The zlib npm package provides compression and decompression functionalities using the zlib library, which is a part of Node.js core. It allows you to compress and decompress data streams and buffers using various algorithms like gzip, deflate, and more.

What are zlib's main functionalities?

Compression using gzip

This code demonstrates how to compress a file using gzip. It reads from 'input.txt' and writes the compressed data to 'input.txt.gz'.

const zlib = require('zlib');
const fs = require('fs');

const input = fs.createReadStream('input.txt');
const output = fs.createWriteStream('input.txt.gz');

input.pipe(zlib.createGzip()).pipe(output);

Decompression using gzip

This code demonstrates how to decompress a gzip file. It reads from 'input.txt.gz' and writes the decompressed data to 'input.txt'.

const zlib = require('zlib');
const fs = require('fs');

const input = fs.createReadStream('input.txt.gz');
const output = fs.createWriteStream('input.txt');

input.pipe(zlib.createGunzip()).pipe(output);

Compression using deflate

This code demonstrates how to compress a file using deflate. It reads from 'input.txt' and writes the compressed data to 'input.txt.deflate'.

const zlib = require('zlib');
const fs = require('fs');

const input = fs.createReadStream('input.txt');
const output = fs.createWriteStream('input.txt.deflate');

input.pipe(zlib.createDeflate()).pipe(output);

Decompression using deflate

This code demonstrates how to decompress a deflate file. It reads from 'input.txt.deflate' and writes the decompressed data to 'input.txt'.

const zlib = require('zlib');
const fs = require('fs');

const input = fs.createReadStream('input.txt.deflate');
const output = fs.createWriteStream('input.txt');

input.pipe(zlib.createInflate()).pipe(output);

Other packages similar to zlib

Readme

Source

NAME

node-zlib - Simple, synchronous deflate/inflate for node.js buffers.

USAGE

Install with npm install zlib.

var Buffer = require('buffer').Buffer;
var zlib = require('zlib');

var input = new Buffer('lorem ipsum dolor sit amet');
var compressed = zlib.deflate(input);
var output = zlib.inflate(compressed);

Note that node-zlib is only intended for small (< 128 KB) data that you already have buffered. It is not meant for input/output streams.

BUILDING

Make sure you have zlib installed. Mac OS X ships with it by default.

To obtain and build the bindings:

git clone git://github.com/kkaefer/node-zlib.git
cd node-zlib
./configure
make

You can also use npm to download and install them:

npm install zlib

TESTS

expresso is required to run unit tests.

npm install expresso
make test

CONTRIBUTORS

LICENSE

node-zlib is BSD licensed.

FAQs

Last updated on 08 Aug 2011

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc