Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
batched-stream
Advanced tools
Transform stream supporting objectMode, which batches a bunch of input data into groups of specified size and will emit arrays, so that you can deal with pieces of input asynchronously.
npm install --save batched-stream
const BatchStream = require('batched-stream')
const batch = new BatchStream({
size : 5, // Bytes or N. of objects (when objectMode is true)
objectMode: true, // false by default
strictMode: false // return the rest of the batch when a stream contains a number of items that is not a strict multiply of the batch size
})
stream
.pipe(batch)
.pipe(new ArrayStream()) // In objectMode: true, deals with array input from pipe.
You can .pipe
other streams to it or .write
them yourself (if you .write
don't forget to .end
). The options are passed down to the transform stream (you can increase the highWaterMark
for example).
If objectMode
is enabled the emitted batches are Array
of length equal to size
. Otherwise Buffer
with byte size
-length are emitted.
The strictMode: false
allows to get the rest of the batch when a stream contains a number of items that is not a strict multiply of the batch size.
npm test
Rocco Musolino (@roccomuso)
MIT
FAQs
Transform a stream into batched items
We found that batched-stream demonstrated a not healthy version release cadence and project activity because the last version was released 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.