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

Node.js 压缩和解压缩库

这些库提供了在 Node.js 环境中处理 ZIP 文件的功能,包括创建、读取和解压缩 ZIP 文件。它们各自具有不同的特性和用例,适用于不同的开发需求和场景。通过这些库,开发者可以轻松地管理文件压缩和解压缩操作,提高应用程序的文件处理效率。

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
adm-zip02,168122 kB1452 个月前MIT
archiver02,95939.6 kB1581 个月前MIT
compressing045756.1 kB522 个月前MIT
node-zip0217-1911 年前-
yauzl080998.1 kB164 天前MIT
yazl037658.7 kB202 年前MIT
zip-lib04470.2 kB19 天前MIT

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

压缩和解压缩功能

  • adm-zip:

    adm-zip 提供简单的压缩和解压缩功能,支持读取和写入 ZIP 文件,适合快速开发和小型项目。

  • archiver:

    archiver 支持多种压缩格式(如 ZIP、TAR),并提供丰富的选项来控制压缩过程,适合复杂的应用需求。

  • compressing:

    compressing 支持多种压缩格式,并提供 Promise API,适合需要异步操作的现代应用。

  • node-zip:

    node-zip 提供基本的压缩和解压缩功能,适合简单的应用场景。

  • yauzl:

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

  • yazl:

    yazl 提供高效的 ZIP 文件创建功能,支持流式 API,适合动态生成 ZIP 文件的场景。

  • zip-lib:

    zip-lib 提供全面的压缩和解压缩功能,支持多种格式,适合需要丰富功能的开发者。

性能

  • adm-zip:

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

  • archiver:

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

  • compressing:

    compressing 设计为高性能,适合处理大文件和高并发场景。

  • node-zip:

    node-zip 性能较为一般,适合小型文件的快速处理。

  • yauzl:

    yauzl 通过流式读取实现高效性能,适合处理大文件而不占用过多内存。

  • yazl:

    yazl 在创建 ZIP 文件时性能优越,特别是在处理大量小文件时。

  • zip-lib:

    zip-lib 性能稳定,适合多种场景,尤其是在需要全面功能时。

API 设计

  • adm-zip:

    adm-zip 的 API 设计简单直观,适合快速上手,适合初学者和快速开发。

  • archiver:

    archiver 提供灵活的 API,适合需要复杂配置的开发者,学习曲线稍陡。

  • compressing:

    compressing 提供现代化的 Promise API,适合现代 JavaScript 开发,易于与异步代码结合。

  • node-zip:

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

  • yauzl:

    yauzl 的 API 设计为流式,适合需要逐步读取文件的场景,学习曲线适中。

  • yazl:

    yazl 的 API 设计为流式,适合动态生成 ZIP 文件,易于使用。

  • zip-lib:

    zip-lib 提供全面的 API,适合需要丰富功能的开发者,文档完善。

社区支持和文档

  • adm-zip:

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

  • archiver:

    archiver 拥有活跃的社区和详细的文档,适合需要深入了解的开发者。

  • compressing:

    compressing 的文档清晰,社区支持较好,适合现代开发者。

  • node-zip:

    node-zip 的文档较为简单,适合快速上手,但社区支持相对较少。

  • yauzl:

    yauzl 的文档清晰,社区支持良好,适合需要流式读取的开发者。

  • yazl:

    yazl 拥有良好的文档和社区支持,适合动态生成 ZIP 文件的开发者。

  • zip-lib:

    zip-lib 拥有全面的文档和活跃的社区支持,适合需要全面功能的开发者。

使用场景

  • adm-zip:

    适合快速开发原型或小型项目,处理简单的 ZIP 文件。

  • archiver:

    适合需要创建复杂 ZIP 文件的应用,支持多种压缩格式。

  • compressing:

    适合处理大文件和高并发场景,支持异步操作。

  • node-zip:

    适合简单的压缩和解压缩需求,适合小型项目。

  • yauzl:

    适合需要高效读取大型 ZIP 文件的场景,尤其是流式读取。

  • yazl:

    适合动态生成 ZIP 文件的场景,特别是在处理大量小文件时。

  • zip-lib:

    适合需要全面功能的开发者,支持多种压缩和解压缩需求。

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

  • adm-zip:

    选择 adm-zip 如果你需要一个简单易用的库来快速处理 ZIP 文件,特别是当你需要读取和写入 ZIP 文件时。它的 API 直观,适合快速开发原型。

  • archiver:

    选择 archiver 如果你需要创建复杂的 ZIP 文件,并且需要支持多种压缩格式。它提供了丰富的功能和灵活性,适合需要高性能和多样化压缩选项的应用。

  • compressing:

    选择 compressing 如果你需要一个现代化的库,支持多种压缩格式,并且希望使用 Promise API 进行异步操作。它适合需要处理大文件和高并发的场景。

  • node-zip:

    选择 node-zip 如果你需要一个轻量级的库来处理 ZIP 文件,特别是当你只需要基本的压缩和解压缩功能时。它的体积小,适合简单的应用。

  • yauzl:

    选择 yauzl 如果你需要高效地读取大型 ZIP 文件,尤其是在需要流式读取的情况下。它提供了流式 API,适合处理大文件而不占用过多内存。

  • yazl:

    选择 yazl 如果你需要高效地创建 ZIP 文件,并且希望使用流式 API 来处理数据。它适合需要动态生成 ZIP 文件的场景。

  • zip-lib:

    选择 zip-lib 如果你需要一个功能全面的库,支持创建和读取 ZIP 文件,并且希望有良好的文档和社区支持。它适合需要全面功能的开发者。

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