# decompress

> Extracting archives made easy

Latest version **4.2.1** (published 2020-04-01) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; high quality score.

Warnings: low downloads; no esm support; has vulnerabilities.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.2.1 |
| Published | 2020-04-01 |
| First published | 2013-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/decompress) |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 8 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 3 |
| Install scripts | no |
| GitHub stars | 419 |
| Author | Kevin Mårtensson |
| Maintainers | kevva, shinnn, sindresorhus |
| Keywords | bz2, bzip2, decompress, extract, tar, tar.bz, tar.gz, zip, unzip |

## Links

- npm: https://www.npmjs.com/package/decompress
- Repository: https://github.com/kevva/decompress
- Homepage: https://github.com/kevva/decompress#readme
- Issues: https://github.com/kevva/decompress/issues
- npm.io page: https://npm.io/package/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.1 (latest) — 2020-04-01
- 0.1.10 (0.1.10) — 2014-08-31
- 0.2.5 (0.2.5) — 2014-08-31
- 4.2.0 — 2017-05-12
- 4.1.0 — 2017-04-25
- 4.0.0 — 2016-05-20
- 3.0.0 — 2015-10-20
- 2.3.0 — 2015-04-12
- 2.2.1 — 2015-03-09
- 2.2.0 — 2015-03-09
- 2.1.2 — 2015-03-09
- 2.1.1 — 2014-10-28
- 2.1.0 — 2014-10-19
- 2.0.0 — 2014-09-13
- 1.0.7 — 2014-09-05
- … 26 more at https://npm.io/package/decompress/versions

## README

# decompress [![Build Status](https://travis-ci.org/kevva/decompress.svg?branch=master)](https://travis-ci.org/kevva/decompress)

> Extracting archives made easy

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

## Install

```
$ npm install decompress
```


## Usage

```js
const decompress = require('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/decompress · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
