# @atomic-reactor/decompress

> Extracting archives made easy

Latest version **4.2.5** (published 2021-06-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @atomic-reactor/decompress
pnpm add @atomic-reactor/decompress
yarn add @atomic-reactor/decompress
bun add @atomic-reactor/decompress
```

## 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 | 4.2.5 |
| Published | 2021-06-25 |
| First published | 2020-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12.13.0 |
| Dependencies | 8 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Kevin Mårtensson |
| Maintainers | camdagr8, jdillick |
| Keywords | bz2, bzip2, decompress, extract, tar, tar.bz, tar.gz, zip, unzip |

## Links

- npm: https://www.npmjs.com/package/@atomic-reactor/decompress
- Repository: https://github.com/Atomic-Reactor/decompress
- Homepage: https://github.com/Atomic-Reactor/decompress#readme
- Issues: https://github.com/Atomic-Reactor/decompress/issues
- npm.io page: https://npm.io/package/@atomic-reactor/decompress

## Dependencies (8)

- [pify](https://npm.io/package/pify.md) ^2.3.0
- [make-dir](https://npm.io/package/make-dir.md) ^1.0.0
- [strip-dirs](https://npm.io/package/strip-dirs.md) ^2.0.0
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.1.10
- [decompress-tar](https://npm.io/package/decompress-tar.md) ^4.0.0
- [decompress-targz](https://npm.io/package/decompress-targz.md) ^4.0.0
- [decompress-unzip](https://npm.io/package/decompress-unzip.md) ^4.0.1
- [decompress-tarbz2](https://npm.io/package/decompress-tarbz2.md) ^4.0.0

## 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

- 4.2.5 (latest) — 2021-06-25
- 4.2.4 — 2020-10-23
- 4.2.3 — 2020-03-17
- 4.2.2 — 2020-03-17
- 4.2.0 — 2020-03-16

## README

# @atomic-reactor/decompress [![Build Status](https://api.travis-ci.org/Atomic-Reactor/decompress.svg?branch=master)](https://github.com/Atomic-Reactor/decompress.git)

Fork of [decompress](https://travis-ci.org/kevva/decompress) to prevent [Zip Slip](https://www.npmjs.com/advisories/1217). This
prevents this problem by filtering out any files that resolve to a parent path.

> Extracting archives made easy

*See [decompress-cli](https://github.com/kevva/decompress-cli) for the command-line version.*

## Install

```
$ npm install @atomic-reactor/decompress
```


## Usage

```js
const decompress = require('@atomic-reactor/decompress');

decompress('unicorn.zip', 'dist').then(files => {
	console.log('done!');
});
```


## API

### decompress(input, [output], [options])

Returns a Promise for an array of files in the following format:

```js
{
	data: Buffer,
	mode: Number,
	mtime: String,
	path: String,
	type: String
}
```

#### input

Type: `string` `Buffer`

File to decompress.

#### output

Type: `string`

Output directory.

#### options

##### filter

Type: `Function`

Filter out files before extracting. E.g:

```js
decompress('unicorn.zip', 'dist', {
	filter: file => path.extname(file.path) !== '.exe'
}).then(files => {
	console.log('done!');
});
```

*Note that in the current implementation, **`filter` is only applied after fully reading all files from the archive in memory**. Do not rely on this option to limit the amount of memory used by `decompress` to the size of the files included by `filter`. `decompress` will read the entire compressed file into memory regardless.*

##### map

Type: `Function`

Map files before extracting: E.g:

```js
decompress('unicorn.zip', 'dist', {
	map: file => {
		file.path = `unicorn-${file.path}`;
		return file;
	}
}).then(files => {
	console.log('done!');
});
```

##### plugins

Type: `Array`<br>
Default: `[decompressTar(), decompressTarbz2(), decompressTargz(), decompressUnzip()]`

Array of [plugins](https://www.npmjs.com/browse/keyword/decompressplugin) to use.

##### strip

Type: `number`<br>
Default: `0`

Remove leading directory components from extracted files.


## License

MIT © [Kevin Mårtensson](https://github.com/kevva)

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