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

unzipper

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unzipper

Unzip cross-platform streaming API

  • 0.12.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3M
increased by0.73%
Maintainers
1
Weekly downloads
 
Created

What is unzipper?

The unzipper npm package is a module that provides streaming APIs for unzipping .zip files. It allows for extracting the contents of zip files, parsing zip file structures, and more, all while being memory efficient and fast.

What are unzipper's main functionalities?

Extracting zip files

This feature allows you to extract the contents of a zip file to a specified directory. The code sample demonstrates how to read a zip file as a stream and pipe it to the unzipper's Extract method, which will extract the files to the given path.

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

fs.createReadStream('path/to/archive.zip')
  .pipe(unzipper.Extract({ path: 'output/path' }));

Parsing zip file entries

This feature allows you to parse the contents of a zip file and work with each entry individually. The code sample shows how to read entries from a zip file and handle them based on their type, either extracting files or draining directories.

const unzipper = require('unzipper');

fs.createReadStream('path/to/archive.zip')
  .pipe(unzipper.Parse())
  .on('entry', function (entry) {
    const fileName = entry.path;
    const type = entry.type; // 'Directory' or 'File'
    if (type === 'File') {
      entry.pipe(fs.createWriteStream('output/path/' + fileName));
    } else {
      entry.autodrain();
    }
  });

Buffer-based extraction

This feature allows you to extract files from a zip file that is already loaded into a buffer. The code sample demonstrates how to open a zip file from a buffer and then extract the contents of the first file into another buffer.

const unzipper = require('unzipper');

unzipper.Open.buffer(buffer)
  .then(function (directory) {
    return directory.files[0].buffer();
  })
  .then(function (contentBuffer) {
    // Use the contentBuffer
  });

Other packages similar to unzipper

Keywords

FAQs

Package last updated on 31 Jul 2024

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