Batch Stream
Transform stream which batches a bunch of input data into groups of specified size. Will emit arrays, so that you can deal with pieces of input asynchronously.
Usage
var batch = size : 100 // the size for each chunk timeout: 5000 // emit data after this amount of milliseconds // even if the size of buffered writes not reaching `size`; stream ; // deals with array input from pipe.
This is also usefull when you want transform continuous writes into batches:
Suppose you have a docs
stream, instead of:
docs
You can:
var batch = { db }) docs
Note that by passing a options.transform
to the constructor, instead of
listening on data
events, the insertions are ensured to be sequential.
If insertions are allowed to happen parrallelly:
var batch = docs
License
the MIT license.