# extract-any-zip

> unzip any type of zip file (buffer, local file or even url) into a directory using 100% javascript

Latest version **2.0.1** (published 2023-02-15) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install extract-any-zip
pnpm add extract-any-zip
yarn add extract-any-zip
bun add extract-any-zip
```

Provides the command `extract-zip`.

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2023-02-15 |
| First published | 2023-02-15 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 10.17.0 |
| Dependencies | 4 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Anthony Mugendi |
| Maintainers | nguru |
| Keywords | unzip, zip, extract, file, buffer, url |

## Links

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

## Dependencies (4)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [yauzl](https://npm.io/package/yauzl.md) ^2.10.0
- [get-stream](https://npm.io/package/get-stream.md) ^5.1.0
- [@types/yauzl](https://npm.io/package/@types/yauzl.md) ^2.9.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 2.0.1 (latest) — 2023-02-15

## README

# extract-any-zip

This module is a clone of the amazing [extract-zip](https://www.npmjs.com/package/extract-zip) with the added ability to unzip urls, buffers as well as files via [file-to-buffer](https://www.npmjs.com/package/file-to-buffer). Everything else in the API remains exactly the same.

Written in pure JavaScript. Extracts a zip into a directory. Available as a library or a command line program.

Uses the [`yauzl`](http://npmjs.org/yauzl) ZIP parser.

[![NPM](https://nodei.co/npm/extract-any-zip.png?global=true)](https://npm.im/extract-zip)
[![Uses JS Standard Style](https://cdn.jsdelivr.net/gh/standard/standard/badge.svg)](https://github.com/standard/standard)
[![Build Status](https://github.com/maxogden/extract-any-zip/workflows/CI/badge.svg)](https://github.com/maxogden/extract-any-zip/actions?query=workflow%3ACI)

## Installation

Make sure you have Node 10 or greater installed.

Get the library:

```
npm install extract-any-zip --save
```

Install the command line program:

```
npm install extract-any-zip -g
```

## JS API

```javascript
const extract = require('extract-any-zip')

async function main () {
  try {
    await extract(source, { dir: target })
    console.log('Extraction complete')
  } catch (err) {
    // handle any errors
  }
}
```

### Source
This is where this module differs with *extract-zip* in that it can take other sources:

Type: `Buffer` `File` `URL`

### Options

- `dir` (required) - the path to the directory where the extracted files are written
- `defaultDirMode` - integer - Directory Mode (permissions), defaults to `0o755`
- `defaultFileMode` - integer - File Mode (permissions), defaults to `0o644`
- `onEntry` - function - if present, will be called with `(entry, zipfile)`, entry is every entry from the zip file forwarded from the `entry` event from yauzl. `zipfile` is the `yauzl` instance

Default modes are only used if no permissions are set in the zip file.

## CLI Usage

```
extract-any-zip foo.zip <targetDirectory>
```

If not specified, `targetDirectory` will default to `process.cwd()`.

---

NOTE: I didn't change version numbers and so this module continues from version `2.0.2` which the the version of `extract-zip` that it was forked from. This is in a bid to retain version compatibility with `extract-zip`.

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