# minipass-collect

> A Minipass stream that collects all the data into a single chunk

Latest version **2.0.1** (published 2023-08-20) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2023-08-20 |
| First published | 2019-09-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16 \|\| 14 >=14.17 |
| Dependencies | 1 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Isaac Z. Schlueter |
| Maintainers | isaacs |

## Links

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

## Dependencies (1)

- [minipass](https://npm.io/package/minipass.md) ^7.0.3

## Recent versions

- 2.0.1 (latest) — 2023-08-20
- 2.0.0 — 2023-08-20
- 1.0.2 — 2019-09-30
- 1.0.1 — 2019-09-15
- 1.0.0 — 2019-09-15

## README

# minipass-collect

A Minipass stream that collects all the data into a single chunk

Note that this buffers ALL data written to it, so it's only good for
situations where you are sure the entire stream fits in memory.

Note: this is primarily useful for the `Collect.PassThrough` class, since
Minipass streams already have a `.collect()` method which returns a promise
that resolves to the array of chunks, and a `.concat()` method that returns
the data concatenated into a single Buffer or String.

## USAGE

```js
const Collect = require('minipass-collect')

const collector = new Collect()
collector.on('data', allTheData => {
  console.log('all the data!', allTheData)
})

someSourceOfData.pipe(collector)

// note that you can also simply do:
someSourceOfData.pipe(new Minipass()).concat().then(data => ...)
// or even, if someSourceOfData is a Minipass:
someSourceOfData.concat().then(data => ...)
// but you might prefer to have it stream-shaped rather than
// Promise-shaped in some scenarios.
```

If you want to collect the data, but _also_ act as a passthrough stream,
then use `Collect.PassThrough` instead (for example to memoize streaming
responses), and listen on the `collect` event.

```js
const Collect = require('minipass-collect')

const collector = new Collect.PassThrough()
collector.on('collect', allTheData => {
  console.log('all the data!', allTheData)
})

someSourceOfData.pipe(collector).pipe(someOtherStream)
```

All [minipass options](http://npm.im/minipass) are supported.

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