# tar-async

> Asynchronous tar and untar

Latest version **1.2.0** (published 2012-06-19) · 0 weekly downloads

## Install

```sh
npm install tar-async
pnpm add tar-async
yarn add tar-async
bun add tar-async
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2012-06-19 |
| First published | 2011-03-20 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.1.90 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | T. Jameson Little |
| Maintainers | beatgammit, coolaj86 |
| Keywords | tar, untar, asynchronous, stream, async, chunk, chunked |

## Links

- npm: https://www.npmjs.com/package/tar-async
- Repository: https://github.com/beatgammit/tar-async
- npm.io page: https://npm.io/package/tar-async

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2012-06-19
- 1.1.4 — 2012-06-19
- 1.1.3 — 2012-06-12
- 1.1.2 — 2012-06-11
- 1.1.1 — 2011-08-07
- 1.1.0 — 2011-06-29
- 1.0.1 — 2011-06-27
- 1.0.0 — 2011-06-27
- 0.3.0 — 2011-05-19
- 0.2.5 — 2011-03-26
- 0.2.0 — 2011-03-21
- 0.1.0 — 2011-03-20

## README

Intro
=====

Tar-async is an async approach to Tar in node.

Tar-async does not directly use the filesystem at all. This makes it really easy to use for practically anything. All that's required to tar something is a filename and data.

No compression is used, so an external compression library is necessary.  This is by design and not likely to be implemented.

Example
=======

Tar:

	var Tar = require('tar-async'), // or require('tar-async').Tar or require('tar-async/tar')
		tape = new Tar({output: require('fs').createWriteStream('out.tar')});
	
	tape.append('test.txt', 'Woohoo!! Tar me up Scotty!', function () {
		tape.close();
	});

Simple huh? A Tar instance is an EventEmitter, and emits these events: 'end', 'data' (and maybe 'error' in the future)

Untar:

	var Untar = require('tar-async/untar'), // or require('tar-async').Untar
		fs = require('fs'),
		untar = new Untar(function (err, header, fileStream) {
			console.log(header.filename);
			fileStream.on('data', function (data) {
				console.log(data.toString());
			});
		});

	fs.createReadStream('out.tar').pipe(untar);

Untar is a Writable Stream, so it's pretty easy to asynchronously untar something.

API
===

Ok, so you want more detail.  Here ya go:

Tar
---

Tar(opts)

Supported options include:

* recordsPerBlock- number of records in a block, default is 20 (don't change unless you know what you're doing)
* consolidate- default false; whether to consolidate everything into a single directory
* normalize- default true; whether to normalize each file's path
* output- default null; writable stream to stream output to
* allowPipe- default false; allow Stream.pipe (this will cache the stream to get the size)

Tar.append(filepath, input, opts, callback):

* filepath- filepath for file when extracted
* input- string or Buffer
* opts- optional options
  * mode- permissions on the file (default 777)
  * mtime- last modified time in seconds (default current time)
  * uid- owner id (default 0)
  * gid- group id (default 0)
  * size- size of output (default input.length; changing this could lead to bad results)
* callback- optional callback; no parameters; called when a record is written

Untar
-----

Untar(opts, callback)

* opts
  * fileTypes- if not defined, defaults to normal and contiguous files; these are the options (any single one or an array of multiple ones)
      * 'normal'- normal file
      * 'hard-link'- hard link
      * 'symbolic-link'- symbolic link
      * 'character-special'- device files that moves data by characters; this type of file usually has a majorNumber and minorNumber
      * 'block-special'- device files that moves data in blocks; this type of file usually has a majorNumber and minorNumber
      * 'directory'- directory
      * 'fifo'- named pipe; doesn't have data
      * 'contiguous-file'- same as file, but it's allocated contiguously on disk
* callback- callback each time a record is read; parameters are
  * err- only used when checksums don't match
  * header- header data (see `header.js` for details
  * fileStream- Readable Stream; chunks will be emitted as Buffer objects

---
_Source: https://npm.io/package/tar-async · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
