# stream-collector

> Buffer data from a stream into an array if a callback is provided

Latest version **1.0.1** (published 2014-11-15) · MIT license · 0 weekly downloads

## Install

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

## 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.1 |
| Published | 2014-11-15 |
| First published | 2014-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

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

## Dependencies (1)

- [once](https://npm.io/package/once.md) ^1.3.1

## Recent versions

- 1.0.1 (latest) — 2014-11-15
- 1.0.0 — 2014-11-15

## README

# stream-collector

Buffer `data` from a stream into an array if a callback is provided

```
npm install stream-collector
```

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

## Usage

``` js
var collect = require('stream-collector')

collect(stream, function(err, list) {
  // list contains all data chunks from stream  
})
```

The `stream` is always returned from the function. If a callback isn't provided no buffering will occur.
This allows you to do the following pattern where if you provide a callback the stream will be buffered (similar to how [request](https://github.com/mikeal/request) works)

``` js
var read = function(cb) {
  var stream = db.createReadStream()
  return collect(stream, cb)
}

var stream = read() // does not buffer

read(function(err, list) {
  // buffers the data
})
```

## License

MIT

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