archiver vs adm-zip vs node-zip vs yauzl vs yazl vs zip-lib
Node.js ZIPライブラリ
archiveradm-zipnode-zipyauzlyazlzip-lib類似パッケージ:

Node.js ZIPライブラリ

ZIPライブラリは、Node.js環境でZIPファイルを作成、操作、解凍するためのツールです。これらのライブラリは、ファイルの圧縮や解凍を簡単に行うことができ、特にデータの転送や保存を効率化するために使用されます。各ライブラリは異なる機能や使用シナリオを持ち、開発者はプロジェクトの要件に応じて最適なものを選択する必要があります。

npmのダウンロードトレンド

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
archiver22,417,5812,94743.1 kB1552年前MIT
adm-zip11,717,2992,159121 kB1482年前MIT
node-zip0217-2011年前-
yauzl079996.3 kB181年前MIT
yazl037558.7 kB191年前MIT
zip-lib04052.6 kB21ヶ月前MIT

機能比較: archiver vs adm-zip vs node-zip vs yauzl vs yazl vs zip-lib

APIの使いやすさ

  • archiver:

    ストリーミングAPIを提供しており、柔軟性が高いですが、やや複雑な設定が必要です。

  • adm-zip:

    シンプルで直感的なAPIを提供し、初心者でも簡単に使い始めることができます。

  • node-zip:

    基本的な機能に特化しており、簡単に使えるが、機能は限られています。

  • yauzl:

    ZIPファイルの読み込みに特化しており、APIはシンプルですが、書き込み機能はありません。

  • yazl:

    ストリーミングAPIを持ち、高速な圧縮が可能ですが、学習コストがやや高いです。

  • zip-lib:

    オブジェクト指向の設計で、使いやすさと拡張性を兼ね備えています。

パフォーマンス

  • archiver:

    ストリーミングを利用することで、大規模なデータの圧縮を効率的に行えます。

  • adm-zip:

    小規模なファイルの圧縮には適していますが、大規模なデータセットの場合はパフォーマンスが低下する可能性があります。

  • node-zip:

    シンプルな実装で、パフォーマンスは良好ですが、機能が限られています。

  • yauzl:

    メモリ効率が良く、大きなZIPファイルの読み込みに適しています。

  • yazl:

    高性能な圧縮を提供し、大規模なデータセットに対しても優れたパフォーマンスを発揮します。

  • zip-lib:

    オブジェクト指向のアプローチにより、パフォーマンスと拡張性を両立しています。

機能の豊富さ

  • archiver:

    多様な圧縮フォーマットをサポートし、機能が豊富です。

  • adm-zip:

    基本的な圧縮・解凍機能を提供しますが、他のライブラリに比べて機能は限られています。

  • node-zip:

    シンプルな機能に特化しており、他のライブラリに比べて機能は少ないです。

  • yauzl:

    読み込み専用の機能に特化しており、圧縮機能はありません。

  • yazl:

    高性能な圧縮機能を持ち、ストリーミングに対応しています。

  • zip-lib:

    カスタマイズ可能な機能を提供し、拡張性があります。

ストリーミングサポート

  • archiver:

    ストリーミングAPIを持ち、大規模なデータの処理に適しています。

  • adm-zip:

    ストリーミング機能は提供していません。

  • node-zip:

    ストリーミング機能はありません。

  • yauzl:

    ZIPファイルの読み込みに特化しており、ストリーミングには対応していません。

  • yazl:

    ストリーミング機能を持ち、高速な圧縮が可能です。

  • zip-lib:

    ストリーミング機能は提供していませんが、オブジェクト指向の設計が特徴です。

学習曲線

  • archiver:

    ストリーミングAPIの理解が必要で、学習曲線はやや急です。

  • adm-zip:

    非常にシンプルで、初心者でもすぐに使いこなせるでしょう。

  • node-zip:

    シンプルなAPIのため、学習は容易です。

  • yauzl:

    特化した機能のため、学習は比較的簡単ですが、書き込み機能がないことに注意が必要です。

  • yazl:

    高性能な機能を持つため、学習曲線はやや急ですが、使いこなせれば非常に強力です。

  • zip-lib:

    オブジェクト指向の設計が特徴で、学習曲線は比較的緩やかです。

選び方: archiver vs adm-zip vs node-zip vs yauzl vs yazl vs zip-lib

  • archiver:

    ストリーミングAPIを利用して大規模なデータを効率的に圧縮したい場合に適しています。多様な圧縮フォーマットをサポートしており、柔軟性があります。

  • adm-zip:

    簡単なAPIとシンプルなZIPファイルの作成・解凍機能を求める場合に最適です。特に小規模なプロジェクトや簡単なタスクに向いています。

  • node-zip:

    シンプルなZIPファイルの作成が必要な場合に適していますが、他のライブラリに比べて機能が限られています。

  • yauzl:

    ZIPファイルの読み込みに特化しており、大きなファイルを扱う際にメモリ効率が良いです。特に読み取り専用の用途に向いています。

  • yazl:

    高性能なZIPファイルの作成に特化しており、ストリーミング機能を持っています。大規模なデータセットの圧縮に適しています。

  • zip-lib:

    オブジェクト指向のアプローチでZIPファイルを操作でき、使いやすさと拡張性を兼ね備えています。特にカスタマイズが必要な場合に向いています。

archiver のREADME

Archiver

A streaming interface for archive generation

Visit the API documentation for a list of all methods available.

Install

npm install archiver --save

Quick Start

// require modules
const fs = require('fs');
const archiver = require('archiver');

// create a file to stream archive data to.
const output = fs.createWriteStream(__dirname + '/example.zip');
const archive = archiver('zip', {
  zlib: { level: 9 } // Sets the compression level.
});

// listen for all archive data to be written
// 'close' event is fired only when a file descriptor is involved
output.on('close', function() {
  console.log(archive.pointer() + ' total bytes');
  console.log('archiver has been finalized and the output file descriptor has closed.');
});

// This event is fired when the data source is drained no matter what was the data source.
// It is not part of this library but rather from the NodeJS Stream API.
// @see: https://nodejs.org/api/stream.html#stream_event_end
output.on('end', function() {
  console.log('Data has been drained');
});

// good practice to catch warnings (ie stat failures and other non-blocking errors)
archive.on('warning', function(err) {
  if (err.code === 'ENOENT') {
    // log warning
  } else {
    // throw error
    throw err;
  }
});

// good practice to catch this error explicitly
archive.on('error', function(err) {
  throw err;
});

// pipe archive data to the file
archive.pipe(output);

// append a file from stream
const file1 = __dirname + '/file1.txt';
archive.append(fs.createReadStream(file1), { name: 'file1.txt' });

// append a file from string
archive.append('string cheese!', { name: 'file2.txt' });

// append a file from buffer
const buffer3 = Buffer.from('buff it!');
archive.append(buffer3, { name: 'file3.txt' });

// append a file
archive.file('file1.txt', { name: 'file4.txt' });

// append files from a sub-directory and naming it `new-subdir` within the archive
archive.directory('subdir/', 'new-subdir');

// append files from a sub-directory, putting its contents at the root of archive
archive.directory('subdir/', false);

// append files from a glob pattern
archive.glob('file*.txt', {cwd:__dirname});

// finalize the archive (ie we are done appending files but streams have to finish yet)
// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand
archive.finalize();

Formats

Archiver ships with out of the box support for TAR and ZIP archives.

You can register additional formats with registerFormat.

You can check if format already exists before to register a new one with isRegisteredFormat.