# continue-stream

> Lazily merge multiple streams in to a single stream

Latest version **3.0.0** (published 2018-05-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install continue-stream
pnpm add continue-stream
yarn add continue-stream
bun add continue-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 | 3.0.0 |
| Published | 2018-05-24 |
| First published | 2014-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tim Hudson |
| Maintainers | timhudson |
| Keywords | lazy, pagination, streams, stream, combine |

## Links

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

## Dependencies (2)

- [end-of-stream](https://npm.io/package/end-of-stream.md) ^1.0.0
- [readable-stream](https://npm.io/package/readable-stream.md) ^2.3.6

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

- 3.0.0 (latest) — 2018-05-24
- 2.0.0 — 2014-09-30
- 1.0.2 — 2014-08-31
- 1.0.1 — 2014-08-28
- 1.0.0 — 2014-08-28

## README

# continue-stream

Lazily merge multiple streams in to a single stream. `continueStream` can also
be thought of as a pagination stream.

```
npm install continue-stream
```

[![build status](http://img.shields.io/travis/timhudson/continue-stream.svg?style=flat)](http://travis-ci.org/timhudson/continue-stream)

## Usage

Pass `continueStream` a function that provides a new stream to it's callback.
This function will be called on initialization and after each stream has ended.
If the callback is called without any arguments the `continueStream` will end.

``` js
var continueStream = require('continue-stream')
var request = require('request')

var page = 1

function next(callback, previousStream) {
  if (page >= 4) return callback()

  var stream = request({
    url: 'https://api.github.com/repos/joyent/node/events?page=' + (page++),
    headers: {'user-agent': 'pug'}
  })

  callback(null, stream)
}

continueStream(next)
  .pipe(process.stdout)

```

Or you can use `continueStream.obj` as a convenience for `objectMode`

``` js
var continueStream = require('continue-stream')
var request = require('request')
var pumpify = require('pumpify')
var JSONStream = require('JSONStream')

var page = 1

function next(callback, previousStream) {
  if (page >= 4) return callback()

  var req = request({
    url: 'https://api.github.com/repos/joyent/node/events?page=' + (page++),
    headers: {'user-agent': 'pug'}
  })

  var stream = pumpify.obj(req, JSONStream.parse('*'))

  callback(null, stream)
}

continueStream.obj(next)
  .on('data', function(data) {
    console.log(data)
  })
```

A good use case for this is paginated requests. Need to read the last `n`
pages of a feed and want all items piped through a single stream? That is
exactly what the last example is showing.

## License

MIT

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