# next-stream

> Concatenate a series of streams 'end-to-end'.

Latest version **2.2.2** (published 2014-12-23) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.2.2 |
| Published | 2014-12-23 |
| First published | 2014-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Anand Thakker |
| Maintainers | anandthakker |
| Keywords | stream, append, join, concatenate |

## Links

- npm: https://www.npmjs.com/package/next-stream
- Repository: https://github.com/anandthakker/next-stream
- Issues: https://github.com/anandthakker/next-stream/issues
- npm.io page: https://npm.io/package/next-stream

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^2.1.0
- [inherits](https://npm.io/package/inherits.md) ^2.0.1
- [readable-stream](https://npm.io/package/readable-stream.md) ^1.0.33

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

- 2.2.2 (latest) — 2014-12-23
- 2.2.1 — 2014-12-23
- 2.2.0 — 2014-12-23
- 2.1.2 — 2014-12-23
- 2.1.1 — 2014-12-22
- 2.1.0 — 2014-12-22
- 2.0.3 — 2014-12-18
- 2.0.2 — 2014-12-16
- 2.0.1 — 2014-12-16
- 2.0.0 — 2014-12-16
- 1.1.0 — 2014-12-15
- 1.0.0 — 2014-12-15

## README

next-stream [![Build Status](https://travis-ci.org/anandthakker/next-stream.svg?branch=master)](https://travis-ci.org/anandthakker/next-stream)
===========

Concatenate/attach a series of streams `a,b,c,...` "end-to-end", so that the 
result streams from `a` until it ends, then moves on to `b` till it ends, etc.

If you don't need mutation, laziness, or non-streams, you should probably just use [stream-cat](https://www.npmjs.com/package/stream-cat).

Supports:
 - **(limited) mutation**: Append additional streams after creation with `push(stream)`.
 - **laziness**: If anything in the series is a function instead of a stream, it will be called
when its 'turn' comes up, and its return value will be used in its place.
 - **non-stream items**: If anything in the series is not a readable stream just push it through as a chunk at the appropriate time.
 - **stream errors**: If any of the given streams in the series emits an error, propagate it.


## Usage

```javascript
var next = require('next-stream');

var stream1 = fs.createReadStream('file1.txt'),
    stream2 = fs.createReadStream('file2.txt'),
    joined = next([stream1, stream2]);

joined.push(fs.createReadStream('file3.txt'));
joined.close(); // tell `joined` to emit `end` when the last stream ends.

joined.pipe(process.stdout);
```

Outputs contents of `file1.txt` followed by contents of `file2.txt` and then
the contents of `file3.txt`.

For convenience, non-stream inputs also work as you'd expect:

```javascript
var next = require('next-stream');

var stream1 = fs.createReadStream('file1.txt'),
stream2 = fs.createReadStream('file2.txt'),
joined = next([stream1, '--------- between ---------', stream2]);

joined.pipe(process.stdout);
```

Outputs contents of `file1.txt`, followed by `'--------- between ---------'`,
followed by contents of `file2.txt`.


## Methods

### var joined = next([stream1, stream2, stream3], opts);

Create a new readable next-stream from the readable streams `stream1`,
`stream2`, `stream3`.

By default, `joined` is in *open-ended* mode, which means it
won't emit `'end'` when the last stream in the list ends. Setting `opts.open`
to `false` causes `joined` to end when the last stream ends.

### joined.push(stream4)

Add `stream4` to the end of the list of streams.

### joined.close()

Close `joined` if it is in open-ended mode.


## Events

### `'next'`

Emitted when we've hit the end event of the current stream.  Event payload
is the next stream, or null if there are none.

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