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

yauzl

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yauzl

yet another unzip library for node

  • 3.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17M
decreased by-2.18%
Maintainers
2
Weekly downloads
 
Created

What is yauzl?

The yauzl npm package is a library for unzipping ZIP files in Node.js. It provides a low-level interface for reading and extracting ZIP file contents, allowing developers to handle large files and read entries without decompressing the entire file to disk.

What are yauzl's main functionalities?

Opening a ZIP file

This code demonstrates how to open a ZIP file for reading. The 'lazyEntries' option allows reading entries one at a time.

const yauzl = require('yauzl');
yauzl.open('path/to/file.zip', {lazyEntries: true}, function(err, zipfile) {
  if (err) throw err;
  zipfile.readEntry();
});

Reading entries from a ZIP file

This code shows how to read entries from an open ZIP file. It handles directories and files differently, reading the next entry after each file is processed.

zipfile.on('entry', function(entry) {
  if (/\/.test(entry.fileName)) {
    // Directory file names end with '/'.
    zipfile.readEntry();
  } else {
    // File entry
    zipfile.openReadStream(entry, function(err, readStream) {
      if (err) throw err;
      // Handle the read stream, possibly piping it somewhere
      readStream.on('end', function() {
        zipfile.readEntry();
      });
    });
  }
});

Extracting a file entry

This code snippet demonstrates how to extract a file entry from a ZIP file. It creates a read stream for the entry and pipes it to a write stream.

zipfile.openReadStream(entry, function(err, readStream) {
  if (err) throw err;
  // Create a write stream to extract the file to
  var writeStream = fs.createWriteStream('output/path');
  readStream.pipe(writeStream);
});

Other packages similar to yauzl

Keywords

FAQs

Package last updated on 03 Nov 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