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

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

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

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

3 年

GitHub Starsランキング

統計詳細

パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
tar-fs37,421,68937817.5 kB15ヶ月前MIT
decompress-tar3,102,80116-109年前MIT
archiver02,94543.1 kB1552年前MIT
tar09042.25 MB109日前BlueOak-1.0.0
tar-stream043632 kB172年前MIT

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

アーカイブ作成機能

  • tar-fs:

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

  • decompress-tar:

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

  • archiver:

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

  • tar:

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

  • tar-stream:

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

ストリーミングサポート

  • tar-fs:

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

  • decompress-tar:

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

  • archiver:

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

  • tar:

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

  • tar-stream:

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

簡単な使用法

  • tar-fs:

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

  • decompress-tar:

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

  • archiver:

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

  • tar:

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

  • tar-stream:

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

パフォーマンス

  • tar-fs:

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

  • decompress-tar:

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

  • archiver:

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

  • tar:

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

  • tar-stream:

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

エコシステムとサポート

  • tar-fs:

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

  • decompress-tar:

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

  • archiver:

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

  • tar:

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

  • tar-stream:

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

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

  • tar-fs:

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

  • decompress-tar:

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

  • archiver:

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

  • tar:

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

  • tar-stream:

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

tar-fs のREADME

tar-fs

Filesystem bindings for tar-stream.

npm install tar-fs

Usage

tar-fs allows you to pack directories into tarballs and extract tarballs into directories.

It doesn't gunzip for you, so if you want to extract a .tar.gz with this you'll need to use something like gunzip-maybe in addition to this.

const tar = require('tar-fs')
const fs = require('fs')

// packing a directory
tar.pack('./my-directory').pipe(fs.createWriteStream('my-tarball.tar'))

// extracting a directory
fs.createReadStream('my-other-tarball.tar').pipe(tar.extract('./my-other-directory'))

To ignore various files when packing or extracting add a ignore function to the options. ignore is also an alias for filter. Additionally you get header if you use ignore while extracting. That way you could also filter by metadata.

const pack = tar.pack('./my-directory', {
  ignore (name) {
    return path.extname(name) === '.bin' // ignore .bin files when packing
  }
})

const extract = tar.extract('./my-other-directory', {
  ignore (name) {
    return path.extname(name) === '.bin' // ignore .bin files inside the tarball when extracing
  }
})

const extractFilesDirs = tar.extract('./my-other-other-directory', {
  ignore (_, header) {
    // pass files & directories, ignore e.g. symlinks
    return header.type !== 'file' && header.type !== 'directory'
  }
})

You can also specify which entries to pack using the entries option

const pack = tar.pack('./my-directory', {
  entries: ['file1', 'subdir/file2'] // only the specific entries will be packed
})

If you want to modify the headers when packing/extracting add a map function to the options

const pack = tar.pack('./my-directory', {
  map (header) {
    header.name = 'prefixed/'+header.name
    return header
  }
})

const extract = tar.extract('./my-directory', {
  map (header) {
    header.name = 'another-prefix/'+header.name
    return header
  }
})

Similarly you can use mapStream incase you wanna modify the input/output file streams

const pack = tar.pack('./my-directory', {
  mapStream (fileStream, header) {
    // NOTE: the returned stream HAS to have the same length as the input stream.
    // If not make sure to update the size in the header passed in here.
    if (path.extname(header.name) === '.js') {
      return fileStream.pipe(someTransform)
    }
    return fileStream
  }
})

const extract = tar.extract('./my-directory', {
  mapStream (fileStream, header) {
    if (path.extname(header.name) === '.js') {
      return fileStream.pipe(someTransform)
    }
    return fileStream
  }
})

Set options.fmode and options.dmode to ensure that files/directories extracted have the corresponding modes

const extract = tar.extract('./my-directory', {
  dmode: parseInt(555, 8), // all dirs should be readable
  fmode: parseInt(444, 8) // all files should be readable
})

It can be useful to use dmode and fmode if you are packing/unpacking tarballs between *nix/windows to ensure that all files/directories unpacked are readable.

Alternatively you can set options.readable and/or options.writable to set the dmode and fmode to readable/writable.

var extract = tar.extract('./my-directory', {
  readable: true, // all dirs and files should be readable
  writable: true, // all dirs and files should be writable
})

Set options.strict to false if you want to ignore errors due to unsupported entry types (like device files)

To dereference symlinks (pack the contents of the symlink instead of the link itself) set options.dereference to true.

Copy a directory

Copying a directory with permissions and mtime intact is as simple as

tar.pack('source-directory').pipe(tar.extract('dest-directory'))

Interaction with tar-stream

Use finalize: false and the finish hook to leave the pack stream open for further entries (see tar-stream#pack), and use pack to pass an existing pack stream.

const mypack = tar.pack('./my-directory', {
  finalize: false,
  finish (sameAsMypack) {
    mypack.entry({name: 'generated-file.txt'}, "hello")
    tar.pack('./other-directory', {
      pack: sameAsMypack
    })
  }
})

License

MIT