adm-zip vs extract-zip vs unzipper
Node.js Zip File Handling Libraries
adm-zipextract-zipunzipperSimilar Packages:

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.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
adm-zip02,162122 kB14418 days agoMIT
extract-zip0398-556 years agoBSD-2-Clause
unzipper047356.6 kB862 years agoMIT

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

Functionality

  • 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.

  • 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.

  • 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

  • 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.

  • 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.

  • 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

  • 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.

  • extract-zip:

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

  • 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

  • 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.

  • extract-zip:

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

  • 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

  • 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.

  • 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.

  • 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: adm-zip vs extract-zip vs unzipper

  • 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.

  • 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.

  • 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 adm-zip

ADM-ZIP for NodeJS

ADM-ZIP is a pure JavaScript implementation for zip data compression for NodeJS.

Build Status

Installation

With npm do:

$ npm install adm-zip

Electron file system support described below.

What is it good for?

The library allows you to:

  • decompress zip files directly to disk or in memory buffers
  • compress files and store them to disk in .zip format or in compressed buffers
  • update content of/add new/delete files from an existing .zip

Dependencies

There are no other nodeJS libraries that ADM-ZIP is dependent of

Examples

Basic usage

var AdmZip = require("adm-zip");

// reading archives
var zip = new AdmZip("./my_file.zip");
var password = "1234567890";
var zipEntries = zip.getEntries(); // an array of ZipEntry records - add password parameter if entries are password protected

zipEntries.forEach(function (zipEntry) {
    console.log(zipEntry.toString()); // outputs zip entries information
    if (zipEntry.entryName == "my_file.txt") {
        console.log(zipEntry.getData().toString("utf8"));
    }
});
// outputs the content of some_folder/my_file.txt
console.log(zip.readAsText("some_folder/my_file.txt"));
// extracts the specified file to the specified location
zip.extractEntryTo(/*entry name*/ "some_folder/my_file.txt", /*target path*/ "/home/me/tempfolder", /*maintainEntryPath*/ false, /*overwrite*/ true);
// extracts everything
zip.extractAllTo(/*target path*/ "/home/me/zipcontent/", /*overwrite*/ true);

// creating archives
var zip = new AdmZip();

// add file directly
var content = "inner content of the file";
zip.addFile("test.txt", Buffer.from(content, "utf8"), "entry comment goes here");
// add local file
zip.addLocalFile("/home/me/some_picture.png");
// get everything as a buffer
var willSendthis = zip.toBuffer();
// or write everything to disk
zip.writeZip(/*target file name*/ "/home/me/files.zip");

// ... more examples in the wiki

For more detailed information please check out the wiki.

Electron original-fs

ADM-ZIP has supported electron original-fs for years without any user interractions but it causes problem with bundlers like rollup etc. For continuing support original-fs or any other custom file system module. There is possible specify your module by fs option in ADM-ZIP constructor.

Example:

const AdmZip = require("adm-zip");
const OriginalFs = require("original-fs");

// reading archives
const zip = new AdmZip("./my_file.zip", { fs: OriginalFs });
.
.
.