# decompress-zip

> Extract files from a ZIP archive

Latest version **0.3.3** (published 2021-01-11) · MIT license · 0 weekly downloads

## Install

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

Provides the command `decompress-zip`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2021-01-11 |
| First published | 2013-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 7 |
| Unpacked size | 31.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 101 |
| Author | Bower |
| Maintainers | paulirish, wibblymat, desandro, sheerun, satazor, sindresorhus |
| Keywords | zip, unzip, tar, untar, compress, decompress, archive, extract, zlib |

## Links

- npm: https://www.npmjs.com/package/decompress-zip
- Repository: https://github.com/bower/decompress-zip
- Homepage: https://github.com/bower/decompress-zip#readme
- Issues: https://github.com/bower/decompress-zip/issues
- npm.io page: https://npm.io/package/decompress-zip

## Dependencies (7)

- [q](https://npm.io/package/q.md) ^1.1.2
- [nopt](https://npm.io/package/nopt.md) ^3.0.1
- [touch](https://npm.io/package/touch.md) 0.0.3
- [binary](https://npm.io/package/binary.md) ^0.3.0
- [mkpath](https://npm.io/package/mkpath.md) ^0.1.0
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.1.3
- [readable-stream](https://npm.io/package/readable-stream.md) ^1.1.8

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

- 0.3.3 (latest) — 2021-01-11
- 0.2.2 — 2019-01-17
- 0.3.2 — 2019-01-17
- 0.3.1 — 2018-03-26
- 0.3.0 — 2016-04-01
- 0.2.1 — 2016-04-01
- 0.2.0 — 2015-05-19
- 0.1.0 — 2015-01-04
- 0.0.8 — 2014-06-02
- 0.0.7 — 2014-05-22
- 0.0.6 — 2014-04-02
- 0.0.5 — 2014-03-12
- 0.0.4 — 2014-01-10
- 0.0.3 — 2013-10-03
- 0.0.2 — 2013-09-26
- … 1 more at https://npm.io/package/decompress-zip/versions

## README

# decompress-zip [![Build Status](https://travis-ci.org/bower/decompress-zip.svg?branch=master)](https://travis-ci.org/bower/decompress-zip) [![Coverage Status](https://coveralls.io/repos/bower/decompress-zip/badge.png?branch=master)](https://coveralls.io/r/bower/decompress-zip?branch=master)

> Extract files from a ZIP archive


## Usage

### .extract(options)

Extracts the contents of the ZIP archive `file`.

Returns an EventEmitter with two possible events - `error` on an error, and `extract` when the extraction has completed. The value passed to the `extract` event is a basic log of each file and how it was compressed.

**Options**
- **path** *String* - Path to extract into (default `.`)
- **follow** *Boolean* - If true, rather than create stored symlinks as symlinks make a shallow copy of the target instead (default `false`)
- **filter** *Function* - A function that will be called once for each file in the archive. It takes one argument which is an object containing details of the file. Return true for any file that you want to extract, and false otherwise. (default `null`)
- **strip** *Number* - Remove leading folders in the path structure. Equivalent to `--strip-components` for tar.
- **restrict** *Boolean* - If true, will restrict files from being created outside `options.path`. Setting to `false` has significant security [implications](https://snyk.io/research/zip-slip-vulnerability) if you are extracting untrusted data. (default `true`)

```js
var DecompressZip = require('decompress-zip');
var unzipper = new DecompressZip(filename)

unzipper.on('error', function (err) {
    console.log('Caught an error');
});

unzipper.on('extract', function (log) {
    console.log('Finished extracting');
});

unzipper.on('progress', function (fileIndex, fileCount) {
    console.log('Extracted file ' + (fileIndex + 1) + ' of ' + fileCount);
});

unzipper.extract({
    path: 'some/path',
    filter: function (file) {
        return file.type !== "SymbolicLink";
    }
});
```

If `path` does not exist, decompress-zip will attempt to create it first.

### .list()

Much like extract, except:
- the success event is `list`
- the data for the event is an array of paths
- no files are actually extracted
- there are no options

```js
var DecompressZip = require('decompress-zip');
var unzipper = new DecompressZip(filename)

unzipper.on('error', function (err) {
    console.log('Caught an error');
});

unzipper.on('list', function (files) {
    console.log('The archive contains:');
    console.log(files);
});

unzipper.list();
```


## License

MIT © Bower team

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