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 檔案的功能。它們各自有不同的特性和使用場景,適合不同的需求和開發者的偏好。使用這些庫可以簡化檔案處理的過程,提升開發效率。

npm下载趋势

3 年

GitHub Stars 排名

统计详情

npm包名称
下载量
Stars
大小
Issues
发布时间
License
adm-zip02,186151 kB612 个月前MIT
archiver02,97939.6 kB1756 个月前MIT
node-zip0217-1912 年前-
yauzl0831110 kB125 个月前MIT
yazl038958.7 kB222 年前MIT
zip-lib04568.8 kB15 个月前MIT

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

功能性

  • adm-zip:

    adm-zip 提供簡單的 API 來讀取和寫入 ZIP 檔案,支持基本的檔案操作,適合快速開發和小型專案。

  • archiver:

    archiver 提供強大的功能,支持多種壓縮格式(如 gzip 和 tar),並且可以流式創建檔案,適合需要高效能的應用。

  • node-zip:

    node-zip 是一個輕量級的庫,主要用於解壓縮 ZIP 檔案,功能簡單,適合不需要複雜功能的場景。

  • yauzl:

    yauzl 專注於高效地讀取 ZIP 檔案,特別適合處理大型檔案,並且支持流式讀取,性能優越。

  • yazl:

    yazl 提供高效的壓縮功能,支持流式創建 ZIP 檔案,適合需要快速壓縮的應用。

  • zip-lib:

    zip-lib 提供全面的壓縮和解壓縮功能,並且有良好的 API 設計,適合各種需求的開發者。

性能

  • adm-zip:

    adm-zip 在處理小型檔案時表現良好,但在處理大型檔案時可能會遇到性能瓶頸。

  • archiver:

    archiver 在創建檔案時性能優越,特別是在流式處理時,能夠有效地處理大量數據。

  • node-zip:

    node-zip 的性能相對較低,適合簡單的解壓縮需求,不建議用於大型檔案。

  • yauzl:

    yauzl 在讀取大型 ZIP 檔案時性能卓越,因為它支持流式讀取,能夠有效管理內存使用。

  • yazl:

    yazl 在壓縮檔案時性能優越,特別是在處理大量小檔案時,能夠快速生成 ZIP 檔案。

  • zip-lib:

    zip-lib 提供穩定的性能,適合各種大小的檔案處理,並且在 API 設計上也考慮了性能優化。

學習曲線

  • adm-zip:

    adm-zip 的 API 簡單明瞭,學習曲線平緩,適合初學者快速上手。

  • archiver:

    archiver 的功能較為複雜,學習曲線稍陡,但提供了豐富的功能,適合需要進階功能的開發者。

  • node-zip:

    node-zip 的使用非常簡單,學習曲線平緩,適合快速解壓縮需求的開發者。

  • yauzl:

    yauzl 的 API 可能需要一些學習,但一旦掌握,能夠高效處理大型檔案。

  • yazl:

    yazl 的學習曲線較平緩,API 設計合理,適合需要快速壓縮的開發者。

  • zip-lib:

    zip-lib 提供了全面的功能,學習曲線稍陡,但對於需要多功能的開發者來說,值得學習。

擴展性

  • adm-zip:

    adm-zip 的擴展性有限,主要適合基本的壓縮和解壓縮需求。

  • archiver:

    archiver 提供良好的擴展性,支持多種格式和流式處理,適合需要擴展功能的應用。

  • node-zip:

    node-zip 的擴展性較差,主要用於簡單的解壓縮需求。

  • yauzl:

    yauzl 的擴展性較好,能夠與其他流式處理庫結合使用,適合需要高效處理的場景。

  • yazl:

    yazl 提供良好的擴展性,能夠方便地與其他庫結合使用,適合需要高性能的應用。

  • zip-lib:

    zip-lib 提供全面的擴展性,適合各種需求的開發者,並且 API 設計合理。

社群支持

  • adm-zip:

    adm-zip 擁有穩定的社群支持,但功能較為基礎,更新頻率較低。

  • archiver:

    archiver 擁有活躍的社群支持,經常更新,適合需要最新功能的開發者。

  • node-zip:

    node-zip 的社群支持較少,更新頻率低,適合簡單需求的開發者。

  • yauzl:

    yauzl 擁有穩定的社群支持,適合需要高效讀取的開發者。

  • yazl:

    yazl 擁有良好的社群支持,經常更新,適合需要高性能的應用。

  • 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 檔案,並且需要支持流式處理和多種壓縮格式。

  • node-zip:

    選擇 node-zip 如果你需要一個輕量級的解壓縮庫,並且不需要過多的功能,適合簡單的解壓需求。

  • yauzl:

    選擇 yauzl 如果你需要一個高效的讀取 ZIP 檔案的庫,特別是當你處理大型檔案時,因為它支持流式讀取。

  • yazl:

    選擇 yazl 如果你需要一個高效的壓縮庫,並且希望能夠以流的方式創建 ZIP 檔案,適合需要高性能的應用。

  • zip-lib:

    選擇 zip-lib 如果你需要一個功能全面的庫,支持創建和解壓縮 ZIP 檔案,並且希望有良好的 API 設計。

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

Security

Please report security vulnerabilities privately. See SECURITY.md.