adm-zip vs archiver vs node-zip vs yauzl vs yazl vs zip-lib
Node.js 压缩和解压缩库
adm-ziparchivernode-zipyauzlyazlzip-lib类似的npm包:

Node.js 压缩和解压缩库

这些库提供了在 Node.js 环境中处理 ZIP 文件的功能,包括创建、读取和解压缩 ZIP 文件。它们各自具有不同的特性和使用场景,适用于不同的需求和开发者偏好。选择合适的库可以提高开发效率和应用性能。

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
adm-zip02,159121 kB1482 年前MIT
archiver02,94743.1 kB1552 年前MIT
node-zip0217-2011 年前-
yauzl079996.3 kB181 年前MIT
yazl037558.7 kB191 年前MIT
zip-lib04052.6 kB21 个月前MIT

功能对比: adm-zip vs archiver vs node-zip vs yauzl vs yazl vs zip-lib

易用性

  • adm-zip:

    adm-zip 提供了简单直观的 API,适合快速上手,适合需要快速创建和解压缩 ZIP 文件的场景。

  • archiver:

    archiver 的 API 设计相对复杂,需要一定的学习成本,但提供了更多的功能和灵活性,适合需要高级功能的用户。

  • node-zip:

    node-zip 的 API 也比较简单,适合基本的压缩和解压缩需求,易于使用。

  • yauzl:

    yauzl 的使用相对复杂,主要用于读取 ZIP 文件,适合需要处理大文件的开发者。

  • yazl:

    yazl 提供了流式写入功能,使用起来相对简单,适合需要创建大型 ZIP 文件的场景。

  • zip-lib:

    zip-lib 提供了全面的功能,使用起来相对复杂,但适合需要多种压缩格式和高级功能的用户。

性能

  • adm-zip:

    adm-zip 在处理小型 ZIP 文件时性能良好,但在处理大型文件时可能会出现性能瓶颈。

  • archiver:

    archiver 在创建大型 ZIP 文件时表现出色,支持流式操作,能够有效管理内存使用。

  • node-zip:

    node-zip 性能较好,适合处理小型文件,但在处理大型文件时可能不如其他库高效。

  • yauzl:

    yauzl 设计用于高效读取大型 ZIP 文件,能够流式处理数据,性能优越。

  • yazl:

    yazl 在创建 ZIP 文件时性能优异,支持流式写入,适合生成大型文件。

  • zip-lib:

    zip-lib 性能表现良好,支持多种压缩格式,适合需要高性能的应用场景。

功能

  • adm-zip:

    adm-zip 提供基本的压缩和解压缩功能,支持文件和目录的操作,功能相对简单。

  • archiver:

    archiver 提供丰富的压缩选项,支持多种格式(如 ZIP、TAR),适合需要复杂压缩需求的场景。

  • node-zip:

    node-zip 提供基本的 ZIP 文件处理功能,适合简单的使用场景。

  • yauzl:

    yauzl 专注于读取 ZIP 文件,支持流式读取,适合处理大文件。

  • yazl:

    yazl 专注于创建 ZIP 文件,支持流式写入,适合生成大型 ZIP 文件。

  • zip-lib:

    zip-lib 提供全面的功能,包括压缩、解压缩和多种格式支持,适合复杂的应用需求。

流式支持

  • adm-zip:

    adm-zip 不支持流式操作,适合小型文件的处理。

  • archiver:

    archiver 支持流式操作,适合处理大型文件和实时生成 ZIP 文件。

  • node-zip:

    node-zip 不支持流式操作,适合简单的压缩和解压缩需求。

  • yauzl:

    yauzl 支持流式读取,适合处理大文件,能够有效管理内存。

  • yazl:

    yazl 支持流式写入,适合生成大型 ZIP 文件,能够有效控制内存使用。

  • zip-lib:

    zip-lib 支持流式操作,适合需要高效处理的场景。

社区支持

  • adm-zip:

    adm-zip 拥有较好的社区支持,文档清晰,适合初学者。

  • archiver:

    archiver 拥有活跃的社区,提供丰富的示例和文档,适合需要深入了解的用户。

  • node-zip:

    node-zip 社区支持一般,文档较少,适合简单使用。

  • yauzl:

    yauzl 社区支持较好,适合需要处理大文件的开发者。

  • yazl:

    yazl 社区支持较好,适合需要创建大型 ZIP 文件的用户。

  • zip-lib:

    zip-lib 拥有活跃的社区,提供全面的文档和示例,适合需要多种功能的用户。

如何选择: adm-zip vs archiver vs node-zip vs yauzl vs yazl vs zip-lib

  • adm-zip:

    选择 adm-zip 如果你需要一个简单易用的库来快速创建和解压缩 ZIP 文件,且不需要复杂的配置或功能。

  • archiver:

    选择 archiver 如果你需要创建大型 ZIP 文件并希望支持流式操作,archiver 提供了强大的压缩选项和灵活性。

  • node-zip:

    选择 node-zip 如果你需要一个轻量级的库来处理 ZIP 文件,且希望使用简单的 API 进行基本的压缩和解压缩操作。

  • yauzl:

    选择 yauzl 如果你需要高效地读取大型 ZIP 文件,yauzl 提供了流式读取功能,适合处理大文件。

  • yazl:

    选择 yazl 如果你需要高效的 ZIP 文件创建,yazl 提供了流式写入功能,适合生成大型 ZIP 文件。

  • zip-lib:

    选择 zip-lib 如果你需要一个功能全面且支持多种压缩格式的库,zip-lib 提供了丰富的功能和灵活性。

adm-zip的README

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 });
.
.
.