archiver vs compressing vs tar vs tar-stream vs zip-stream
ファイル圧縮ライブラリ
archivercompressingtartar-streamzip-stream類似パッケージ:

ファイル圧縮ライブラリ

ファイル圧縮ライブラリは、データを圧縮して保存したり、圧縮されたデータを解凍したりするためのツールです。これらのライブラリは、さまざまなフォーマット(ZIP、TARなど)をサポートしており、ファイルの転送やストレージの効率を向上させるために使用されます。特に、Webアプリケーションでは、データの転送量を削減し、パフォーマンスを向上させるために、圧縮が重要な役割を果たします。

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

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
archiver02,94843.1 kB1562年前MIT
compressing045453.6 kB492ヶ月前MIT
tar09122.24 MB914日前BlueOak-1.0.0
tar-stream043732.1 kB181ヶ月前MIT
zip-stream01679.33 kB271年前MIT

機能比較: archiver vs compressing vs tar vs tar-stream vs zip-stream

圧縮形式のサポート

  • archiver:

    Archiverは、ZIP、TAR、GZなど、複数の圧縮形式をサポートしています。特に、ZIP形式の作成に強みがあります。

  • compressing:

    Compressingは、ZIP、GZ、BROTLIなど、多様な圧縮形式をサポートしており、ユーザーはニーズに応じた圧縮方法を選択できます。

  • tar:

    Tarは、主にTAR形式に特化しており、Unix系システムとの互換性が高いです。

  • tar-stream:

    Tar-streamは、TAR形式に特化しており、ストリーミングでの圧縮・解凍が可能です。

  • zip-stream:

    Zip-streamは、ZIP形式に特化しており、ストリーミングでの圧縮を実現しています。

ストリーミングサポート

  • archiver:

    Archiverは、ストリーミングAPIを提供しており、大きなファイルを扱う際に便利です。メモリを効率的に使用できます。

  • compressing:

    Compressingは、ストリーミング圧縮をサポートしており、リアルタイムでデータを圧縮できます。

  • tar:

    Tarは、ストリーミング機能はありませんが、ファイルを一括でアーカイブするのに適しています。

  • tar-stream:

    Tar-streamは、ストリーミングAPIを提供し、リアルタイムでの圧縮・解凍が可能です。

  • zip-stream:

    Zip-streamは、ストリーミング形式でZIPファイルを生成するため、メモリ効率が良く、リアルタイムでの圧縮が可能です。

圧縮率

  • archiver:

    Archiverは、一般的な圧縮率を提供し、使いやすさとパフォーマンスのバランスが取れています。

  • compressing:

    Compressingは、高圧縮率を提供し、特にデータサイズを小さくすることに重点を置いています。

  • tar:

    Tarは、圧縮率はそれほど高くありませんが、アーカイブ機能に特化しています。

  • tar-stream:

    Tar-streamは、圧縮率は標準的ですが、ストリーミング処理に優れています。

  • zip-stream:

    Zip-streamは、ZIP形式の圧縮率を提供し、使いやすさとパフォーマンスを兼ね備えています。

使用の簡便さ

  • archiver:

    Archiverは、シンプルなAPIを提供しており、すぐに使い始めることができます。

  • compressing:

    Compressingは、さまざまなオプションを提供しますが、設定がやや複雑になることがあります。

  • tar:

    Tarは、シンプルなコマンドラインツールとして使用でき、使いやすいです。

  • tar-stream:

    Tar-streamは、ストリーミングAPIを利用するため、少し学習が必要ですが、効率的です。

  • zip-stream:

    Zip-streamは、ストリーミング形式で簡単にZIPファイルを生成でき、使いやすいです。

パフォーマンス

  • archiver:

    Archiverは、メモリ効率が良く、大きなファイルを扱う際に優れたパフォーマンスを発揮します。

  • compressing:

    Compressingは、高圧縮率を提供するため、圧縮に時間がかかることがありますが、結果は優れています。

  • tar:

    Tarは、アーカイブの速度が速く、シンプルな操作で効率的です。

  • tar-stream:

    Tar-streamは、ストリーミング処理に特化しており、大きなデータセットを扱う際に優れたパフォーマンスを発揮します。

  • zip-stream:

    Zip-streamは、ストリーミングでの圧縮が可能で、メモリ効率が良く、リアルタイムでの処理が可能です。

選び方: archiver vs compressing vs tar vs tar-stream vs zip-stream

  • archiver:

    Archiverは、簡単にZIPやTARファイルを作成したい場合に最適です。ストリーミングAPIを利用しており、大きなファイルを扱う際にもメモリを効率的に使用できます。

  • compressing:

    Compressingは、さまざまな圧縮形式をサポートしており、特に高圧縮率を求める場合に適しています。複数の圧縮アルゴリズムを選択できるため、ニーズに応じた最適な圧縮を行えます。

  • tar:

    Tarは、Unix系システムで広く使用されているフォーマットで、特にファイルのアーカイブに特化しています。シンプルさと互換性を重視する場合に選択すると良いでしょう。

  • tar-stream:

    Tar-streamは、ストリーミングAPIを提供しており、メモリ使用量を抑えつつ、リアルタイムでデータを圧縮・解凍したい場合に適しています。大きなデータセットを扱う際に便利です。

  • zip-stream:

    Zip-streamは、ストリーミング形式で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.