extract-zip vs adm-zip vs unzipper
Node.js Zip File Handling Libraries Comparison
1 Year
extract-zipadm-zipunzipperSimilar Packages:
What's Node.js Zip File Handling Libraries?

Zip file handling libraries in Node.js provide developers with tools to create, extract, and manipulate zip files easily. These libraries simplify the process of working with compressed files, enabling efficient storage and transfer of data. They are essential for applications that need to package multiple files into a single archive or extract files from a zip archive for processing. Each library offers unique features and functionalities tailored to different use cases, making it important to choose the right one based on project requirements.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
extract-zip13,958,599392-515 years agoBSD-2-Clause
adm-zip6,569,7872,084121 kB1446 months agoMIT
unzipper3,868,90544956.6 kB817 months agoMIT
Feature Comparison: extract-zip vs adm-zip vs unzipper

Functionality

  • extract-zip:

    extract-zip focuses solely on extracting files from zip archives. It provides a simple API for decompressing zip files, ensuring that developers can quickly retrieve files without additional overhead.

  • adm-zip:

    adm-zip offers both creation and extraction of zip files, allowing developers to easily package files into a zip archive or extract them. It supports adding files and directories, making it versatile for various use cases.

  • unzipper:

    unzipper provides a streaming interface for extracting files, allowing for efficient handling of large zip files. It supports processing files as they are extracted, which is beneficial for applications that need to handle data incrementally.

Performance

  • extract-zip:

    extract-zip is optimized for performance during extraction, ensuring that it can handle large zip files efficiently. Its focus on extraction allows for faster processing times compared to libraries that also handle creation.

  • adm-zip:

    adm-zip operates synchronously, which can lead to performance issues when handling large files or multiple files at once. However, for smaller tasks, it performs adequately without the need for complex setups.

  • unzipper:

    unzipper excels in performance when dealing with large zip files due to its streaming capabilities. It minimizes memory usage by processing files on-the-fly, making it suitable for applications where performance is critical.

Ease of Use

  • extract-zip:

    extract-zip offers a simple and intuitive API focused solely on extraction, making it easy to integrate into projects without unnecessary complexity.

  • adm-zip:

    adm-zip is known for its straightforward API, making it easy for developers to get started quickly. Its synchronous nature simplifies the coding process, especially for those new to zip file handling.

  • unzipper:

    unzipper has a steeper learning curve due to its streaming model, but it provides powerful features for advanced users. Developers may need to familiarize themselves with streams to fully leverage its capabilities.

Error Handling

  • extract-zip:

    extract-zip includes robust error handling specifically for extraction processes, allowing developers to catch and manage errors related to file extraction effectively.

  • adm-zip:

    adm-zip provides basic error handling mechanisms, but developers need to implement additional checks for edge cases, such as corrupted zip files or unsupported formats.

  • unzipper:

    unzipper offers comprehensive error handling for streaming operations, enabling developers to manage errors at various stages of the extraction process, which is crucial for maintaining application stability.

Community and Support

  • extract-zip:

    extract-zip has a smaller community but provides clear documentation, making it easy to find answers for common issues. However, it may lack extensive community resources.

  • adm-zip:

    adm-zip has a moderate level of community support, with documentation available but fewer resources compared to more popular libraries. Users may find community forums helpful for troubleshooting.

  • unzipper:

    unzipper has a growing community and offers good documentation, along with examples. Its streaming capabilities have attracted a user base that values performance, leading to more shared knowledge and resources.

How to Choose: extract-zip vs adm-zip vs unzipper
  • extract-zip:

    Select extract-zip if your primary requirement is to extract files from zip archives with a focus on simplicity and performance. It is designed specifically for extraction, making it a lightweight option for projects that do not require zip file creation.

  • adm-zip:

    Choose adm-zip if you need a straightforward API for both creating and extracting zip files. It is particularly useful for applications that require synchronous operations and ease of use, making it suitable for quick tasks and smaller projects.

  • unzipper:

    Opt for unzipper if you need a streaming approach to handle large zip files or require more advanced features like handling zip entries individually. It is ideal for applications that need to process files on-the-fly without loading the entire archive into memory.

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().