Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zlib

Package Overview
Dependencies
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zlib

Simple, synchronous deflate/inflate for buffers

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
267K
decreased by-14.97%
Maintainers
5
Weekly downloads
 
Created

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

FAQs

Package last updated on 08 Aug 2011

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc