extract-zip vs unzipper vs decompress-zip vs decompress
Node.js File Extraction Libraries
extract-zipunzipperdecompress-zipdecompressSimilar Packages:

Node.js File Extraction Libraries

File extraction libraries in Node.js are essential tools for developers who need to handle compressed files in various formats. These libraries provide functionality to decompress and extract files from archives, enabling seamless file management and manipulation within applications. They support different compression formats, making it easier to work with files downloaded from the internet or packaged for distribution. Choosing the right library depends on specific project requirements, such as the types of archives to be handled, performance considerations, and ease of use.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
extract-zip23,657,027397-536 years agoBSD-2-Clause
unzipper7,992,35547456.6 kB862 years agoMIT
decompress-zip150,053102-295 years agoMIT
decompress0417-466 years agoMIT

Feature Comparison: extract-zip vs unzipper vs decompress-zip vs decompress

Supported Formats

  • extract-zip:

    Exclusively handles .zip files with a straightforward API, making it easy to extract contents without additional complexity.

  • unzipper:

    Primarily focused on .zip files and streams, providing a powerful interface for both extraction and streaming of files.

  • decompress-zip:

    Specifically designed for .zip files, making it a focused solution for projects that primarily deal with this format.

  • decompress:

    Supports multiple formats including .zip, .tar, .gz, .bz2, and more, allowing for flexible file handling in various scenarios.

Ease of Use

  • extract-zip:

    Provides a very straightforward API for extracting .zip files, ideal for developers looking for a no-frills approach.

  • unzipper:

    While slightly more complex, it offers advanced features like streaming extraction, which can be beneficial for larger files.

  • decompress-zip:

    Designed for simplicity, it allows quick extraction of .zip files with just a few lines of code, making it beginner-friendly.

  • decompress:

    Offers a simple and intuitive API, making it easy for developers to implement file extraction with minimal setup and configuration.

Performance

  • extract-zip:

    Highly efficient for .zip files, focusing on performance and speed during extraction operations.

  • unzipper:

    Offers streaming capabilities which can improve performance for large .zip files, allowing for on-the-fly extraction.

  • decompress-zip:

    Optimized for .zip files, ensuring quick extraction times and minimal resource usage for this specific format.

  • decompress:

    Performance varies based on the format being extracted, but it is generally efficient for handling multiple formats in a single library.

Streaming Support

  • extract-zip:

    Does not support streaming; it is a simple extraction tool for .zip files without additional features.

  • unzipper:

    Provides robust streaming support, allowing files to be extracted directly to streams, which is useful for large files or when integrating with other stream-based processes.

  • decompress-zip:

    No streaming support; designed for straightforward extraction of .zip files.

  • decompress:

    Does not inherently support streaming, focusing instead on batch extraction of files from various formats.

Community and Maintenance

  • extract-zip:

    Maintained with a focus on .zip extraction, but may not have as large a community as more general libraries.

  • unzipper:

    Has a solid community and is actively maintained, especially for those needing advanced streaming capabilities.

  • decompress-zip:

    Well-maintained, but with a narrower focus on .zip files, which may limit community contributions compared to more versatile libraries.

  • decompress:

    Actively maintained with a growing community, ensuring ongoing support and updates for various formats.

How to Choose: extract-zip vs unzipper vs decompress-zip vs decompress

  • decompress:

    Choose 'decompress' if you need a versatile library that supports multiple archive formats (including .zip, .tar, .gz, etc.) and want a simple API for extracting files. It is ideal for projects requiring broad format support.

README for extract-zip

extract-zip

Unzip written in pure JavaScript. Extracts a zip into a directory. Available as a library or a command line program.

Uses the yauzl ZIP parser.

NPM Uses JS Standard Style Build Status

Installation

Make sure you have Node 10 or greater installed.

Get the library:

npm install extract-zip --save

Install the command line program:

npm install extract-zip -g

JS API

const extract = require('extract-zip')

async function main () {
  try {
    await extract(source, { dir: target })
    console.log('Extraction complete')
  } catch (err) {
    // handle any errors
  }
}

Options

  • dir (required) - the path to the directory where the extracted files are written
  • defaultDirMode - integer - Directory Mode (permissions), defaults to 0o755
  • defaultFileMode - integer - File Mode (permissions), defaults to 0o644
  • onEntry - function - if present, will be called with (entry, zipfile), entry is every entry from the zip file forwarded from the entry event from yauzl. zipfile is the yauzl instance

Default modes are only used if no permissions are set in the zip file.

CLI Usage

extract-zip foo.zip <targetDirectory>

If not specified, targetDirectory will default to process.cwd().