tar-fs
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
mkdirp-classic | 0.5.3 | 1.91 kB | MIT | prod | |
pump | 3.0.0 | 3.16 kB | MIT | prod | |
tar-stream | 3.1.7 | 9.54 kB | MIT | prod |
Tar-fs is an npm package that provides filesystem bindings for tar-stream. It is designed to pack directories into tarballs and extract tarballs into directories. It is ideal for handling tarball files in JavaScript applications, but note that it does not support gunzip on its own. To work with .tar.gz
files, it is recommended to use another utility, such as gunzip-maybe, in conjunction with tar-fs.
Using tar-fs is relatively straightforward. After installing the package via npm with npm install tar-fs
, you can incorporate it into your project with the required statement like const tar = require('tar-fs')
.
Here is an example of how to use tar-fs to pack a directory into a tarball:
const tar = require('tar-fs')
const fs = require('fs')
// packing a directory
tar.pack('./my-directory').pipe(fs.createWriteStream('my-tarball.tar'))
And to extract a tarball into a directory, use the following:
// extracting a directory
fs.createReadStream('my-other-tarball.tar').pipe(tar.extract('./my-other-directory'))
It also provides additional options like filtering specific files when packing or extracting, defining entries to pack, modifying the headers, altering input/output file streams, setting file/directory modes, and more.
Documentation and examples for tar-fs can be found in the README file in its GitHub repository at https://github.com/mafintosh/tar-fs.git. This README includes details about the package's functions and options, as well as code examples. For an intensive understanding of the tar-fs package and its full capabilities, it is a great resource.