# targz

> TarGz for NodeJS

Latest version **1.0.1** (published 2015-08-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install targz
pnpm add targz
yarn add targz
bun add targz
```

## Health

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

Positive: has types package; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-08-02 |
| First published | 2015-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/targz) |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Miska Kaipiainen |
| Maintainers | miskun |
| Keywords | targz, tar.gz, tar, gz, gzip, node |

## Links

- npm: https://www.npmjs.com/package/targz
- Repository: https://github.com/miskun/targz
- Homepage: https://github.com/miskun/targz#readme
- Issues: https://github.com/miskun/targz/issues
- npm.io page: https://npm.io/package/targz

## Dependencies (1)

- [tar-fs](https://npm.io/package/tar-fs.md) ^1.8.1

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-08-02
- 1.0.0 — 2015-07-30

## README

# TarGz for NodeJS

Simple tar.gz compression and decompression for NodeJS.

## Installation

```
npm install targz
```

## Simple Usage

```javascript

var targz = require('targz');

// compress files into tar.gz archive
targz.compress({
    src: 'path_to_files',
    dest: 'path_to_compressed_file'
}, function(err){
    if(err) {
        console.log(err);
    } else {
        console.log("Done!");
    }
});

// decompress files from tar.gz archive
targz.decompress({
    src: 'path_to_compressed file',
    dest: 'path_to_extract'
}, function(err){
    if(err) {
        console.log(err);
    } else {
        console.log("Done!");
    }
});

```

## Advanced Usage

You can adjust tar and gzip/gunzip parameters by using optional parameters. The API:

```javascript

// Compress API
targz.compress( options, callback );

// Decompress API
targz.decompress( options, callback );

```

Where supported options are:

* **src** - (String) The path to files to be compressed
* **dest** - (String) The path to tar.gz file to be created
* **tar** - (Object) Adjust tar options. See [tar-fs](https://github.com/mafintosh/tar-fs) docs for details. OPTIONAL.
  * **ignore** - (Function) Ignore/filter files
  * **entries** - (Array) Define list of files
  * **map** - (Function) Modify the headers
  * **mapStream** - (Function) Modify the input/output file streams
  * **dmode** - (Number) Set the permissions for directories
  * **fmode** - (Number) Set permissions for files
  * **strict** - (Boolean) Ignore errors due to unsupported entry types (like device files). Default: true
  * **dereference** - (Boolean) Pack the contents of the symlink instead of the link itself. Default: false
* **gz** - (Object) Adjust gzip/gunzip options. See [zlib](https://nodejs.org/api/zlib.html#zlib_options) docs for details. OPTIONAL.

**Example**

```javascript

var targz = require('targz');

// compress files into tar.gz archive while filtering all .bin files and having gzip level/memLevel set to 6
targz.compress({
    src: 'path_to_files',
    dest: 'path_to_compressed_file',
    tar: {
        ignore: function(name) {
            return path.extname(name) === '.bin' // ignore .bin files when packing
        }
    },
    gz: {
        level: 6;
        memLevel: 6;
    }
}, function(err){
    if(err) {
        console.log(err);
    } else {
        console.log("Done!");
    }
});

```

## License

MIT

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