# stream-zip

> zip together multiple streams into a single stream

Latest version **1.0.6** (published 2016-12-02) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.6 |
| Published | 2016-12-02 |
| First published | 2016-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Anton Mokrushin |
| Maintainers | amokrushin |

## Links

- npm: https://www.npmjs.com/package/stream-zip
- npm.io page: https://npm.io/package/stream-zip

## Recent versions

- 1.0.6 (latest) — 2016-12-02
- 1.0.5 — 2016-12-02
- 1.0.4 — 2016-12-02
- 1.0.3 — 2016-12-02
- 1.0.2 — 2016-11-30
- 1.0.1 — 2016-11-30

## README

# stream-zip
[![Latest Stable Version](https://img.shields.io/npm/v/stream-zip.svg)](https://www.npmjs.com/package/stream-zip)
[![Build Status](https://img.shields.io/travis/amokrushin/stream-zip/master.svg)](https://travis-ci.org/amokrushin/stream-zip)
[![Test Coverage](https://img.shields.io/codecov/c/github/amokrushin/stream-zip/master.svg)](https://codecov.io/github/amokrushin/stream-zip?branch=master)
[![Dependency Status](https://img.shields.io/david/amokrushin/stream-zip.svg)](https://david-dm.org/amokrushin/stream-zip)
[![License](https://img.shields.io/npm/l/stream-zip.svg)](https://raw.githubusercontent.com/amokrushin/stream-zip/master/LICENSE.txt)

Combine multiple streams into a single stream

## Features
 * back-pressure support
 * handling errors from piped streams

## Install
 
```
npm install stream-zip
```

## Example

### Incomplete source

```javascript
const { PassThrough } = require('stream');
const Zip = require('stream-zip');

const zip = new Zip();
const ps1 = new PassThrough({ objectMode: true });
const ps2 = new PassThrough({ objectMode: true });
const ps3 = new PassThrough({ objectMode: true });

ps1.pipe(zip);
ps2.pipe(zip);
ps3.pipe(zip);

ps1.write(1);
ps1.write(2);
ps1.write(3);
ps1.end(4);

ps2.write('a');
ps2.write('b');
ps2.write('c');
ps2.end('d');

ps3.write({});
ps3.write([]);
ps3.write(new Error('oops'));
ps3.write(false);
ps3.end('extra chunk');

zip.on('data', data => console.log(data));
zip.on('end', () => console.log('ZIP END'));

/*
 * Console output:
 *  [ 1, 'a', {} ]
 *  [ 2, 'b', [] ]
 *  [ 3, 'c', Error: oops ]
 *  [ 4, 'd', false ]
 *  ZIP END
 */
```

### Source error handling

```js
const { PassThrough } = require('stream');
const Zip = require('..');

const zip = new Zip({ forwardErrors: 'pass' });
const ps1 = new PassThrough({ objectMode: true });
const ps2 = new PassThrough({ objectMode: true });

ps1.pipe(zip);
ps2.pipe(zip);

ps1.write(1);
ps1.write(2);
ps1.write(3);
ps1.end();

ps2.write('a');
ps2.emit('error', new Error('oops'));

zip.on('data', data => console.log(data));
zip.on('end', () => console.log('ZIP END'));

/*
 * Console output:
 *  [ 1, 'a' ]
 *  [ 2, Error: oops ]
 *  ZIP END
 */
```

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