# never-ending-stream

> concatenate multiple streams

Latest version **2.0.0** (published 2016-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install never-ending-stream
pnpm add never-ending-stream
yarn add never-ending-stream
bun add never-ending-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.0.0 |
| Published | 2016-01-25 |
| First published | 2015-02-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Matteo Collina |
| Maintainers | matteo.collina |
| Keywords | stream, restart, never, ends, autorestart, concat |

## Links

- npm: https://www.npmjs.com/package/never-ending-stream
- Repository: https://github.com/mcollina/never-ending-stream
- Issues: https://github.com/mcollina/never-ending-stream/issues
- npm.io page: https://npm.io/package/never-ending-stream

## Dependencies (2)

- [through2](https://npm.io/package/through2.md) ^2.0.0
- [end-of-stream](https://npm.io/package/end-of-stream.md) ^1.1.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

- 2.0.0 (latest) — 2016-01-25
- 1.1.2 — 2015-04-10
- 1.1.1 — 2015-02-03
- 1.1.0 — 2015-02-02
- 1.0.0 — 2015-02-02

## README

# never-ending-stream

Automatically restarts your stream for you when it ends.
This can be easily use to concatenate multiple streams.

## Usage

```js
'use strict'

var nes = require('never-ending-stream')
var from = require('from2')
var chunks = [new Buffer('hello'), new Buffer('world')]
var count = 0

var stream = nes(function () {
  if (count++ === 2) {
    // close the stream after 2 runs
    return null
  }

  var source = [].concat(chunks)

  return from.obj(function (size, next) {
    var chunk = source.shift() || null
    next(null, chunk)
  })
})

// prints
//  hello
//  world
//  hello
//  world
stream.on('data', function (data) {
  console.log(data.toString())
})
```

## API

### neverEndingStream([opts,] build([cb]))

Creates a binary never-ending stream, by concatenating all streams
generated by `build`. `build` is called whenever the
previous stream completes.

`build` can be synchronous or asynchronous:

* if it accepts no callback, is synchronous, and it should return the
  stream, or `null` to close the `never-ending-stream`.

* if it accepts a callback, is asynchronous, and you should call the
  callback when the next stream is ready, like `cb(null, stream)`.

All other options will be passed to [through2](http://npm.im/through2).

### neverEndingStream.obj([opts, ], build([cb]))

Like `neverEndingStream()`, but with `objectMode: true` by default.

## License

MIT

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