Sha256: 2fcdd1a11d4dc927519e6801c59119fb9743173b510f2e30b99c4e3a6b7c3432

Contents?: true

Size: 1.47 KB

Versions: 42

Compression:

Stored size: 1.47 KB

Contents

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

Version data entries

42 entries across 41 versions & 7 rubygems

Version Path
immosquare-cleaner-0.1.52 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.51 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.50 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.49 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.48 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.47 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.46 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.45 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.44 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.43 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.42 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.41 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.40 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.39 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.38 node_modules/minipass-collect/README.md
optimacms-0.1.61 spec/dummy/node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.32 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.31 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.30 node_modules/minipass-collect/README.md
immosquare-cleaner-0.1.29 node_modules/minipass-collect/README.md