archiver vs adm-zip vs jszip vs node-zip vs zip-a-folder vs zip-lib
Node.jsのZIPライブラリ
archiveradm-zipjszipnode-zipzip-a-folderzip-lib類似パッケージ:

Node.jsのZIPライブラリ

これらのライブラリは、Node.js環境でZIPファイルを作成、解凍、操作するためのツールです。開発者は、ファイルを圧縮して保存したり、複数のファイルを一つのアーカイブにまとめたりすることができます。これにより、データの転送や保存が効率的に行えるようになります。

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

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
archiver18,351,0722,95243.1 kB1562年前MIT
adm-zip02,161121 kB1482年前MIT
jszip010,322762 kB410-(MIT OR GPL-3.0-or-later)
node-zip0217-2011年前-
zip-a-folder076146 kB06日前MIT
zip-lib04152.6 kB15日前MIT

機能比較: archiver vs adm-zip vs jszip vs node-zip vs zip-a-folder vs zip-lib

APIのシンプルさ

  • archiver:

    archiverは、ストリーミングAPIを使用しており、少し複雑ですが、柔軟性が高く、さまざまな圧縮形式をサポートしています。大きなファイルを扱う際に特に有用です。

  • adm-zip:

    adm-zipは、シンプルで直感的なAPIを提供しており、ZIPファイルの作成や解凍が容易です。特に、少ないコードで操作が可能なため、初心者にも扱いやすいです。

  • jszip:

    jszipは、ブラウザ環境でも動作するため、クライアントサイドでのZIP操作が可能です。APIはシンプルで、使いやすさが特徴です。

  • node-zip:

    node-zipは、シンプルなAPIを持ち、Node.js環境に特化しています。基本的なZIP操作を迅速に実行できます。

  • zip-a-folder:

    zip-a-folderは、フォルダ全体を簡単にZIP化できるAPIを提供しています。特定のフォルダを指定するだけで圧縮が可能です。

  • zip-lib:

    zip-libは、豊富な機能を持つAPIを提供しており、非同期処理やストリームの操作が可能です。高機能なZIP操作が求められる場合に適しています。

圧縮形式のサポート

  • archiver:

    archiverは、ZIPだけでなく、tarやgzipなど、さまざまな圧縮形式をサポートしています。多様なニーズに応えることができます。

  • adm-zip:

    adm-zipは、基本的なZIP形式のみをサポートしていますが、シンプルな使用には十分です。

  • jszip:

    jszipは、主にZIP形式を扱いますが、ブラウザ環境での使用に特化しているため、特にクライアントサイドでの操作に優れています。

  • node-zip:

    node-zipは、基本的なZIP形式をサポートし、Node.js環境でのシンプルな操作に焦点を当てています。

  • zip-a-folder:

    zip-a-folderは、フォルダをZIP形式に圧縮することに特化しており、他の形式には対応していません。

  • zip-lib:

    zip-libは、ZIP形式に加え、さまざまな圧縮形式をサポートしており、柔軟な使用が可能です。

パフォーマンス

  • archiver:

    archiverは、ストリーミングを利用するため、大きなファイルを効率的に処理できます。メモリ使用量を抑えつつ、高速な処理が可能です。

  • adm-zip:

    adm-zipは、メモリ内で全てのファイルを操作するため、大きなファイルを扱う際にはパフォーマンスが低下する可能性があります。

  • jszip:

    jszipは、ブラウザ環境での使用を考慮しており、パフォーマンスは良好ですが、大きなファイルを扱う際には注意が必要です。

  • node-zip:

    node-zipは、シンプルな処理を行うため、パフォーマンスは良好ですが、大規模なファイルには向いていません。

  • zip-a-folder:

    zip-a-folderは、フォルダ全体を圧縮する際に、パフォーマンスが良好ですが、特定の条件下で遅くなることがあります。

  • zip-lib:

    zip-libは、非同期処理をサポートしており、大きなファイルやフォルダを効率的に処理することができます。

非同期処理のサポート

  • archiver:

    archiverは、ストリーミングAPIを使用しており、非同期処理に優れています。大きなファイルを効率的に扱うことができます。

  • adm-zip:

    adm-zipは、非同期処理をサポートしていないため、大きなファイルの処理には不向きです。

  • jszip:

    jszipは、非同期操作をサポートしており、特にブラウザ環境での使用に適しています。

  • node-zip:

    node-zipは、非同期処理をサポートしておらず、シンプルな操作に特化しています。

  • zip-a-folder:

    zip-a-folderは、非同期処理をサポートしていませんが、簡単なフォルダ圧縮には適しています。

  • zip-lib:

    zip-libは、非同期処理をサポートしており、複雑な操作にも対応可能です。

使用シナリオ

  • archiver:

    archiverは、大きなファイルや多くのファイルを扱う必要があるプロジェクトに適しています。

  • adm-zip:

    adm-zipは、簡単なZIPファイルの作成や解凍が必要な小規模なプロジェクトに最適です。

  • jszip:

    jszipは、ブラウザでのZIP操作が必要な場合に最適です。

  • node-zip:

    node-zipは、Node.js環境でのシンプルなZIP操作に向いています。

  • zip-a-folder:

    zip-a-folderは、フォルダ全体を圧縮する必要がある場合に便利です。

  • zip-lib:

    zip-libは、高機能なZIP操作が求められるプロジェクトに適しています。

選び方: archiver vs adm-zip vs jszip vs node-zip vs zip-a-folder vs zip-lib

  • archiver:

    ストリーミングAPIを使用して大きなファイルを扱う必要がある場合に適しています。多様な圧縮形式をサポートしており、柔軟性があります。

  • adm-zip:

    簡単なZIPファイルの作成や解凍が必要な場合に最適です。シンプルなAPIを提供しており、迅速な実装が可能です。

  • jszip:

    ブラウザ環境でも動作するZIPライブラリが必要な場合に選択してください。クライアントサイドでのZIPファイルの生成や操作が可能です。

  • node-zip:

    シンプルなZIP操作が必要で、特にNode.jsの環境に特化したい場合に適しています。

  • zip-a-folder:

    フォルダ全体を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.