Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
minipass-collect
Advanced tools
A Minipass stream that collects all the data into a single chunk
Weekly downloads
Package description
The minipass-collect package is a Node.js stream utility that collects all the data from a stream and then emits a 'collect' event with the collected data. It is built on top of the Minipass stream library, which is a minimal pass-through stream implementation.
Data collection from streams
This feature allows you to collect all the data from a stream. When the stream ends, the 'collect' event is emitted with the collected data as its argument.
const Collect = require('minipass-collect')
const collectStream = new Collect()
collectStream.on('collect', data => {
console.log('Collected data:', data)
})
collectStream.write('some data')
collectStream.end()
concat-stream is a writable stream that concatenates all the data from a stream and calls a callback with the result. It is similar to minipass-collect but uses callbacks instead of emitting an event.
Buffer List (bl) is a storage object for collections of Node Buffers, which can also be a stream. It is similar to minipass-collect in that it collects stream data, but it also provides more features for manipulating the collected data.
get-stream is a module to get a stream as a string or buffer. It's similar to minipass-collect but focuses on promise-based API and does not use events.
Readme
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.
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.
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 are supported.
FAQs
A Minipass stream that collects all the data into a single chunk
The npm package minipass-collect receives a total of 11,618,338 weekly downloads. As such, minipass-collect popularity was classified as popular.
We found that minipass-collect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.