archiver vs decompress-tar vs tar vs tar-fs vs tar-stream
アーカイブおよび圧縮ライブラリ
archiverdecompress-tartartar-fstar-stream類似パッケージ:

アーカイブおよび圧縮ライブラリ

これらのライブラリは、ファイルやディレクトリを圧縮または解凍するためのツールを提供します。ウェブ開発において、データの転送や保存の効率を向上させるために、アーカイブ形式は非常に重要です。これらのライブラリは、さまざまなアーカイブ形式(tar、zipなど)を扱うための機能を提供し、開発者が簡単にファイル操作を行えるようにします。

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

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
archiver02,94843.1 kB1562年前MIT
decompress-tar016-109年前MIT
tar09122.24 MB913日前BlueOak-1.0.0
tar-fs038218.2 kB11ヶ月前MIT
tar-stream043732.1 kB181ヶ月前MIT

機能比較: archiver vs decompress-tar vs tar vs tar-fs vs tar-stream

アーカイブ作成機能

  • archiver:

    archiverは、zipやtarなどの複数のアーカイブ形式をサポートしており、柔軟なアーカイブ作成が可能です。ストリーミングに対応しているため、大きなファイルの処理にも適しています。

  • decompress-tar:

    decompress-tarは、tarファイル専用の解凍ライブラリで、シンプルなAPIを提供します。特定の形式に特化しているため、使いやすさが特徴です。

  • tar:

    tarは、tar形式のアーカイブを作成および解凍するための基本的な機能を提供します。シンプルで直感的なインターフェースを持っています。

  • tar-fs:

    tar-fsは、tarアーカイブをファイルシステムとして扱うことができ、ストリーミングでの読み書きが可能です。大規模なデータ処理に適しています。

  • tar-stream:

    tar-streamは、tarアーカイブをストリーミングで処理するためのライブラリで、メモリ効率が良く、リアルタイムでのデータ処理に向いています。

ストリーミングサポート

  • archiver:

    archiverは、ストリーミングAPIを提供しており、大きなファイルを効率的に処理できます。データを逐次的に処理する必要がある場合に非常に便利です。

  • decompress-tar:

    decompress-tarは、ストリーミング解凍をサポートしていないため、大きなファイルを扱う場合には不向きです。

  • tar:

    tarは、ストリーミング機能を持たないため、すべてのデータをメモリに読み込む必要があります。

  • tar-fs:

    tar-fsは、ストリーミングでのファイル操作を可能にし、メモリ使用量を最小限に抑えます。大きなデータセットを扱う際に特に有用です。

  • tar-stream:

    tar-streamは、ストリーミングAPIを提供し、データをリアルタイムで処理することができます。大規模なデータの処理に最適です。

簡単な使用法

  • archiver:

    archiverは、使いやすいAPIを提供しており、簡単にアーカイブを作成できます。ドキュメントも充実しているため、学習コストが低いです。

  • decompress-tar:

    decompress-tarは、シンプルなAPIを持ち、tarファイルの解凍が簡単に行えます。特に初心者に優しい設計です。

  • tar:

    tarは、基本的な機能に特化しており、シンプルな使用法が特徴です。

  • tar-fs:

    tar-fsは、ストリーミングファイルシステムの概念を持ち、少し学習が必要ですが、効率的なファイル操作が可能です。

  • tar-stream:

    tar-streamは、ストリーミング処理を行うためのAPIがやや複雑ですが、強力な機能を提供します。

パフォーマンス

  • archiver:

    archiverは、ストリーミング処理を活用することで、大きなファイルのアーカイブ作成時に高いパフォーマンスを発揮します。

  • decompress-tar:

    decompress-tarは、tarファイル専用の解凍に特化しているため、パフォーマンスが良好です。

  • tar:

    tarは、シンプルな操作のため、パフォーマンスが安定していますが、メモリ使用量が多くなる場合があります。

  • tar-fs:

    tar-fsは、ストリーミング処理により、メモリ効率が良く、大きなデータセットを扱う際に優れたパフォーマンスを発揮します。

  • tar-stream:

    tar-streamは、ストリーミング処理を行うため、メモリ使用量を抑えつつ高いパフォーマンスを実現します。

エコシステムとサポート

  • archiver:

    archiverは、広く使用されているため、コミュニティが活発で、サポートやドキュメントが充実しています。

  • decompress-tar:

    decompress-tarは、特定の機能に特化しているため、サポートは限られていますが、シンプルさが魅力です。

  • tar:

    tarは、基本的な機能を提供するため、他のライブラリとの組み合わせが容易です。

  • tar-fs:

    tar-fsは、ストリーミング処理に特化しており、他のストリーミングライブラリと組み合わせて使うことができます。

  • tar-stream:

    tar-streamは、ストリーミング処理を行うため、他のストリーミングライブラリとの統合が容易です。

選び方: archiver vs decompress-tar vs tar vs tar-fs vs tar-stream

  • archiver:

    アーカイバは、さまざまな形式(zip、tarなど)でアーカイブを作成する必要がある場合に最適です。特に、ストリーミング機能が必要な場合に便利です。

  • decompress-tar:

    decompress-tarは、tarファイルを解凍するためのシンプルで軽量なライブラリです。tar形式のファイルを扱う場合に特化しているため、他の形式が不要な場合に適しています。

  • tar:

    tarは、tarアーカイブを作成および操作するための基本的な機能を提供します。シンプルで効率的な操作が求められる場合に選択するべきです。

  • tar-fs:

    tar-fsは、tarアーカイブをファイルシステムとして扱うことができるライブラリです。ストリームを使用してファイルを読み書きする必要がある場合に適しています。

  • tar-stream:

    tar-streamは、tarアーカイブをストリーミングで作成および解凍するためのライブラリです。大きなファイルを扱う際にメモリ効率が良く、ストリーミング処理が必要な場合に最適です。

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.