# collect-all

> Returns a stream which becomes readable once all input is received

Latest version **1.0.4** (published 2020-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install collect-all
pnpm add collect-all
yarn add collect-all
bun add collect-all
```

## 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.4 |
| Published | 2020-09-26 |
| First published | 2015-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 2 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Lloyd Brookes |
| Maintainers | 75lb |
| Keywords | concat, stream, collect, buffers, concentate |

## Links

- npm: https://www.npmjs.com/package/collect-all
- Repository: https://github.com/75lb/collect-all
- Homepage: https://github.com/75lb/collect-all#readme
- Issues: https://github.com/75lb/collect-all/issues
- npm.io page: https://npm.io/package/collect-all

## Dependencies (2)

- [stream-via](https://npm.io/package/stream-via.md) ^1.0.4
- [stream-connect](https://npm.io/package/stream-connect.md) ^1.0.2

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2020-09-26
- 1.0.3 — 2017-06-10
- 1.0.2 — 2016-04-14
- 1.0.1 — 2016-02-13
- 1.0.0 — 2016-02-04
- 0.2.1 — 2016-01-02
- 0.2.0 — 2015-12-22
- 0.1.0 — 2015-07-03
- 0.0.0 — 2015-07-02

## README

[![view on npm](https://img.shields.io/npm/v/collect-all.svg)](https://www.npmjs.org/package/collect-all)
[![npm module downloads](https://img.shields.io/npm/dt/collect-all.svg)](https://www.npmjs.org/package/collect-all)
[![Build Status](https://travis-ci.org/75lb/collect-all.svg?branch=master)](https://travis-ci.org/75lb/collect-all)
[![Dependency Status](https://david-dm.org/75lb/collect-all.svg)](https://david-dm.org/75lb/collect-all)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)

<a name="module_collect-all"></a>

***DEPRECATED. This package has been replaced by [stream-read-all](https://github.com/75lb/stream-read-all) which does the same job but with a Promises interface.***


## collect-all
Returns a stream which fires a callback and becomes readable once all input is received.

By default the callback is invoked with a Buffer instance containing all concatenated input. If you set the option `{ objectMode: true }` the callback is invoked with an array containing all objects received.

<a name="exp_module_collect-all--collectAll"></a>

### collectAll([callback], [options]) ⇒ [<code>Duplex</code>](https://nodejs.org/api/stream.html#stream_class_stream_duplex) ⏏
**Kind**: Exported function

| Param | Type | Description |
| --- | --- | --- |
| [callback] | <code>function</code> | Called once with the collected input data (by default a `Buffer` instance, or array in `objectMode`.). The value returned by this callback function will be passed downstream. |
| [options] | <code>object</code> | [Stream options](https://nodejs.org/dist/latest-v5.x/docs/api/stream.html#stream_new_stream_readable_options) object, passed to the constructor for the stream returned by `collect-all`. If the callback function supplied returns a non-string/buffer value, set `options.objectMode` to `true`. |

**Example**
An example command-line client script - string input received at stdin is stamped with `received` then written to  stdout.
```js
var collectAll = require('collect-all')
process.stdin
  .pipe(collectAll(function (input) {
    input = 'received: ' + input
    return input
  }))
  .pipe(process.stdout)
```

An object-mode example:
```js
var collectAll = require('collect-all')

function onAllCollected (collected) {
  console.log('Objects collected: ' + collected.length)
}

var stream = collectAll(onAllCollected, { objectMode: true })
stream.write({})
stream.write({})
stream.end({}) // outputs 'Objects collected: 3'
```

* * *

&copy; 2015-17 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

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