adm-zip vs archiver vs node-zip vs yazl vs zip-a-folder vs zip-dir
Node.js 压缩库
adm-ziparchivernode-zipyazlzip-a-folderzip-dir类似的npm包:

Node.js 压缩库

这些库提供了在 Node.js 环境中创建、读取和操作 ZIP 文件的功能。它们各自有不同的特性和使用场景,适用于不同的需求,例如简单的文件压缩、流式处理或与文件系统的集成。选择合适的库可以帮助开发者更高效地处理文件压缩和解压缩的任务。

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
adm-zip02,159121 kB1482 年前MIT
archiver02,95443.1 kB1562 年前MIT
node-zip0217-2011 年前-
yazl037558.7 kB191 年前MIT
zip-a-folder076146 kB017 天前MIT
zip-dir047-205 年前MIT

功能对比: adm-zip vs archiver vs node-zip vs yazl vs zip-a-folder vs zip-dir

易用性

  • adm-zip:

    adm-zip 提供了简单直观的 API,适合快速上手和基本的 ZIP 文件操作。

  • archiver:

    archiver 的 API 设计较为复杂,适合需要流式处理和多格式支持的用户。

  • node-zip:

    node-zip 的 API 也相对简单,但功能较为基础,适合轻量级需求。

  • yazl:

    yazl 提供了简单的接口,专注于高效的 ZIP 文件创建,易于使用。

  • zip-a-folder:

    zip-a-folder 旨在提供简单的文件夹压缩功能,API 友好,易于理解。

  • zip-dir:

    zip-dir 提供了非常简洁的接口,适合快速压缩目录,使用方便。

性能

  • adm-zip:

    adm-zip 在处理小文件时表现良好,但在处理大文件时可能会遇到性能瓶颈。

  • archiver:

    archiver 支持流式压缩,适合处理大文件和实时数据流,性能优越。

  • node-zip:

    node-zip 性能一般,适合轻量级的文件操作。

  • yazl:

    yazl 在处理大量小文件时表现出色,能够有效减少内存使用。

  • zip-a-folder:

    zip-a-folder 在压缩整个文件夹时性能良好,适合快速操作。

  • zip-dir:

    zip-dir 性能稳定,适合简单的目录压缩任务。

功能支持

  • adm-zip:

    adm-zip 支持基本的 ZIP 文件创建和解压缩,但不支持流式处理。

  • archiver:

    archiver 支持多种格式(如 zip 和 tar),并且可以进行流式压缩,功能强大。

  • node-zip:

    node-zip 主要支持基本的 ZIP 操作,功能较为有限。

  • yazl:

    yazl 专注于高效的 ZIP 文件创建,功能简单明了。

  • zip-a-folder:

    zip-a-folder 专注于文件夹压缩,功能单一但实用。

  • zip-dir:

    zip-dir 支持目录压缩,功能简单,易于使用。

社区支持

  • adm-zip:

    adm-zip 拥有较大的用户基础和社区支持,文档齐全。

  • archiver:

    archiver 是一个流行的库,拥有活跃的社区和良好的文档支持。

  • node-zip:

    node-zip 的社区较小,文档相对简单。

  • yazl:

    yazl 也有一定的社区支持,但相对较少。

  • zip-a-folder:

    zip-a-folder 社区较小,但提供了简单的使用示例。

  • zip-dir:

    zip-dir 社区支持有限,但文档清晰易懂。

兼容性

  • adm-zip:

    adm-zip 兼容性良好,支持多种 Node.js 版本。

  • archiver:

    archiver 兼容性强,支持 Node.js 的多个版本和流式操作。

  • node-zip:

    node-zip 兼容性一般,适合基本的 Node.js 应用。

  • yazl:

    yazl 兼容性良好,适合现代 Node.js 环境。

  • zip-a-folder:

    zip-a-folder 兼容性良好,适合大多数 Node.js 应用。

  • zip-dir:

    zip-dir 兼容性强,适合多种 Node.js 版本。

如何选择: adm-zip vs archiver vs node-zip vs yazl vs zip-a-folder vs zip-dir

  • adm-zip:

    选择 adm-zip 如果你需要一个简单易用的库来处理 ZIP 文件的创建和解压缩,特别是当你需要在内存中操作文件时。

  • archiver:

    选择 archiver 如果你需要支持流式压缩和多种格式(如 tar 和 zip),并且希望能够处理大文件或实时数据流。

  • node-zip:

    选择 node-zip 如果你需要一个轻量级的库来处理基本的 ZIP 文件操作,且不需要太多的额外功能。

  • yazl:

    选择 yazl 如果你需要高效的 ZIP 文件创建,特别是在处理大量小文件时,yazl 提供了更好的性能。

  • zip-a-folder:

    选择 zip-a-folder 如果你需要快速地压缩整个文件夹,且希望简单易用的 API。

  • zip-dir:

    选择 zip-dir 如果你需要一个简单的工具来压缩目录,且希望支持 Promise 和回调的方式。

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