# multistream

> A stream that emits multiple other streams one after another (streams3)

Latest version **4.1.0** (published 2021-02-04) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2021-02-04 |
| First published | 2014-07-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/multistream) |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 293 |
| Author | Feross Aboukhadijeh |
| Maintainers | mafintosh, feross |
| Keywords | combine streams, join streams, concat streams, multiple streams, combine, join, concat, multiple, file stream, append, append streams, combiner, joiner |

## Links

- npm: https://www.npmjs.com/package/multistream
- Repository: https://github.com/feross/multistream
- Issues: https://github.com/feross/multistream/issues
- Funding: https://github.com/sponsors/feross
- npm.io page: https://npm.io/package/multistream

## Dependencies (2)

- [once](https://npm.io/package/once.md) ^1.4.0
- [readable-stream](https://npm.io/package/readable-stream.md) ^3.6.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 4.1.0 (latest) — 2021-02-04
- 4.0.1 — 2020-10-27
- 4.0.0 — 2019-08-06
- 3.1.0 — 2019-08-04
- 3.0.0 — 2019-06-28
- 2.1.1 — 2018-05-25
- 2.1.0 — 2016-07-23
- 2.0.5 — 2016-03-11
- 2.0.4 — 2016-02-28
- 2.0.3 — 2016-02-11
- 2.0.2 — 2015-08-10
- 2.0.1 — 2015-08-10
- 2.0.0 — 2015-08-10
- 1.6.1 — 2015-08-04
- 1.6.0 — 2015-08-04
- … 11 more at https://npm.io/package/multistream/versions

## README

# multistream [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]

[travis-image]: https://img.shields.io/travis/feross/multistream/master.svg
[travis-url]: https://travis-ci.org/feross/multistream
[npm-image]: https://img.shields.io/npm/v/multistream.svg
[npm-url]: https://npmjs.org/package/multistream
[downloads-image]: https://img.shields.io/npm/dm/multistream.svg
[downloads-url]: https://npmjs.org/package/multistream
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com

#### A stream that emits multiple other streams one after another (streams3)

[![Sauce Test Status](https://saucelabs.com/browser-matrix/multistream.svg)](https://saucelabs.com/u/multistream)

![cat](https://raw.githubusercontent.com/feross/multistream/master/img.jpg)

Simple, robust streams3 version of [combined-stream](https://www.npmjs.org/package/combined-stream). Allows you to combine multiple streams into a single stream. When the first stream ends, the next one starts, and so on, until all streams are consumed.

This module is used by [WebTorrent](http://webtorrent.io), specifically [create-torrent](https://github.com/feross/create-torrent).

### install

```
npm install multistream
```

### usage

Use `multistream` like this:

```js
var MultiStream = require('multistream')
var fs = require('fs')

var streams = [
  fs.createReadStream(__dirname + '/numbers/1.txt'),
  fs.createReadStream(__dirname + '/numbers/2.txt'),
  fs.createReadStream(__dirname + '/numbers/3.txt')
]

new MultiStream(streams).pipe(process.stdout) // => 123
```

You can also create an object-mode stream with `MultiStream.obj(streams)`.

To lazily create the streams, wrap them in a function:

```js
var streams = [
  fs.createReadStream(__dirname + '/numbers/1.txt'),
  function () { // will be executed when the stream is active
    return fs.createReadStream(__dirname + '/numbers/2.txt')
  },
  function () { // same
    return fs.createReadStream(__dirname + '/numbers/3.txt')
  }
]

new MultiStream(streams).pipe(process.stdout) // => 123
```

Alternatively, streams may be created by an asynchronous "factory" function:

```js
var count = 0
function factory (cb) {
  if (count > 3) return cb(null, null)
  count++
  setTimeout(function () {
    cb(null, fs.createReadStream(__dirname + '/numbers/' + count + '.txt'))
  }, 100)
}

new MultiStream(factory).pipe(process.stdout) // => 123
```

### contributors

- [Feross Aboukhadijeh](http://feross.org)
- [Mathias Buus](https://github.com/mafintosh/)
- [Yuri Astrakhan](https://github.com/nyurik/)

### license

MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org).

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