# onezip

> pack and extract .zip archives with emitter

Latest version **7.0.3** (published 2026-10-15) · MIT license · 0 weekly downloads

## Install

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

Provides the command `onezip`.

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 7.0.3 |
| Published | 2026-10-15 |
| First published | 2016-11-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 8 |
| Unpacked size | 22.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | coderaiser |
| Maintainers | coderaiser |
| Keywords | extract, zip, unzip, pack |

## Links

- npm: https://www.npmjs.com/package/onezip
- Repository: https://github.com/coderaiser/node-onezip
- Issues: https://github.com/coderaiser/node-onezip/issues
- npm.io page: https://npm.io/package/onezip

## Dependencies (8)

- [glob](https://npm.io/package/glob.md) ^13.0.6
- [yazl](https://npm.io/package/yazl.md) ^3.3.1
- [yauzl](https://npm.io/package/yauzl.md) ^3.1.3
- [currify](https://npm.io/package/currify.md) ^4.0.0
- [findit2](https://npm.io/package/findit2.md) ^2.2.3
- [pipe-io](https://npm.io/package/pipe-io.md) ^4.0.0
- [try-to-catch](https://npm.io/package/try-to-catch.md) ^4.0.5
- [yargs-parser](https://npm.io/package/yargs-parser.md) ^22.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

- 7.0.3 (latest) — 2026-10-15
- 7.0.2 — 2026-03-29
- 7.0.1 — 2026-02-26
- 7.0.0 — 2026-02-26
- 6.1.1 — 2024-12-04
- 6.1.0 — 2024-05-14
- 6.0.2 — 2024-02-01
- 6.0.1 — 2024-02-01
- 6.0.0 — 2024-02-01
- 5.0.0 — 2021-01-05
- 4.2.3 — 2020-12-27
- 4.2.2 — 2020-08-13
- 4.2.1 — 2020-06-24
- 4.2.0 — 2020-05-03
- 4.1.0 — 2020-04-23
- … 28 more at https://npm.io/package/onezip/versions

## README

# OneZip [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]

[LicenseURL]: https://tldrlegal.com/license/mit-license "MIT License"
[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat
[NPMURL]: https://npmjs.org/package/onezip "npm"
[NPMIMGURL]: https://img.shields.io/npm/v/onezip.svg?style=flat
[BuildStatusURL]: https://github.com/coderaiser/node-onezip/actions/workflows/nodejs.yml "Build Status"
[BuildStatusIMGURL]: https://github.com/coderaiser/node-onezip/actions/workflows/nodejs.yml/badge.svg
[CoverageURL]: https://coveralls.io/github/coderaiser/node-onezip?branch=master
[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/node-onezip/badge.svg?branch=master&service=github

Pack and extract .zip archives with emitter.

## Global

`onezip` could be installed global with

```
npm i onezip -g
```

And used this way:

```
Usage: onezip [filename]
Options:
  -h, --help      display this help and exit
  -v, --version   output version information and exit
  -p, --pack      pack files to archive
  -x, --extract   extract files from archive
```

## Local

`onezip` could be used locally. It will emit event on every packed/extracted file.
Good for making progress bars.

## Install

```
npm i onezip --save
```

## How to use?

### pack(from, to, names)

- `from`  - **string** directory that would be packed
- `to`    - **string** or **stream**, name of archive
- `names` - **array** of names in directory `from` that would be packed.

```js
import path from 'node:path';
import {onezip} from 'onezip';

const cwd = process.cwd();
const name = 'pipe.tar.gz';
const from = `${cwd}/pipe-io`;
const to = path.join(cwd, name);

const pack = onezip.pack(from, to, ['LICENSE', 'README.md', 'package.json']);

pack.on('file', (name) => {
    console.log(name);
});

pack.on('start', () => {
    console.log('start packing');
});

pack.on('progress', (percent) => {
    console.log(`${percent}%`);
});

pack.on('error', (error) => {
    console.error(error);
});

pack.on('end', () => {
    console.log('done');
});
```

### extract(from, to)

- `from` - path to **.zip** archive
- `to` - path to directory where files would be stored.

```js
import path from 'node:path';
import {onezip} from 'onezip';

const cwd = process.cwd();
const name = 'pipe.zip';
const to = `${cwd}/pipe-io`;
const from = path.join(cwd, name);

const extract = onezip.extract(from, to);

extract.on('file', (name) => {
    console.log(name);
});

extract.on('start', (percent) => {
    console.log('extracting started');
});

extract.on('progress', (percent) => {
    console.log(`${percent}%`);
});

extract.on('error', (error) => {
    console.error(error);
});

extract.on('end', () => {
    console.log('done');
});
```

In case of starting example output should be similar to (but with additional events):

```
33%
67%
100%
done
```

## Related

- [Jag](https://github.com/coderaiser/node-jag "Jag") - Pack files and folders with tar and gzip.
- [Jaguar](https://github.com/coderaiser/node-jaguar "Jaguar") - Pack and extract .tar.gz archives with emitter.
- [Tar-to-zip](https://github.com/coderaiser/node-tar-to-zip "Tar-to-zip") - Convert tar and tar.gz archives to zip.

## License

MIT

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