Socket
Socket
Sign inDemoInstall

@types/yauzl

Package Overview
Dependencies
2
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/yauzl

TypeScript definitions for yauzl


Version published
Maintainers
1
Weekly downloads
10,532,596
increased by0.47%
Install size
1.61 MB

Weekly downloads

Package description

What is @types/yauzl?

The @types/yauzl package provides TypeScript type definitions for the yauzl package, which is a library for unzipping files. These type definitions allow TypeScript developers to use yauzl in their projects with the benefits of TypeScript's static type checking. The main functionalities of yauzl, and thus @types/yauzl, revolve around reading and extracting zip files.

What are @types/yauzl's main functionalities?

Opening a zip file

This code demonstrates how to open a zip file using yauzl. It uses the `open` method, specifying the path to the zip file and options, then reads the first entry in the zip file.

import * as yauzl from 'yauzl';
yauzl.open('path/to/file.zip', {lazyEntries: true}, (err, zipfile) => {
  if (err) throw err;
  zipfile.readEntry();
});

Reading entries from a zip file

This code snippet is used within the context of an open zipfile object. It listens for 'entry' events, which occur each time a new entry in the zip file is ready to be read, logging the file name of each entry and then reading the next entry.

zipfile.on('entry', (entry) => {
  console.log(`Entry: ${entry.fileName}`);
  zipfile.readEntry();
});

Extracting file entries

This example shows how to extract files from a zip archive. It checks if the entry is a file (not a directory) and then creates a read stream for that entry. The stream is piped to a write stream that writes the file to a specified output path.

zipfile.on('entry', (entry) => {
  if (/\/.test(entry.fileName)) {
    zipfile.readEntry();
  } else {
    zipfile.openReadStream(entry, (err, readStream) => {
      if (err) throw err;
      readStream.on('end', () => {
        zipfile.readEntry();
      });
      readStream.pipe(fs.createWriteStream('output/path/' + entry.fileName));
    });
  }
});

Other packages similar to @types/yauzl

Readme

Source

Installation

npm install --save @types/yauzl

Summary

This package contains type definitions for yauzl (https://github.com/thejoshwolfe/yauzl).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yauzl.

Additional Details

  • Last updated: Mon, 11 Apr 2022 02:01:17 GMT
  • Dependencies: @types/node
  • Global values: none

Credits

These definitions were written by Florian Keller.

FAQs

Last updated on 11 Apr 2022

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc