Package Exports
- batched-stream
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (batched-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Batched Stream
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.
Install
npm install --save batched-stream
Usage
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 - objectModeis enabled the emitted batches are- Arrayof length equal to- size. Otherwise- Bufferwith byte- size-length are emitted.
- The - strictMode: falseallows 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.
Test
npm test
Author
Rocco Musolino (@roccomuso)
License
MIT
