combines floods of small stream writes while not delaying or buffering writes when not flooded. buffers only up to configured amount and only keeps buffer around for at most configured interval.
var fs = require('fs')
, floody = require('floody')
, ws = fs.createWriteStream('file.txt')
;
var flood = floody(ws);
// imaginary function that produces thousands of lines of data
var thousandsOfLines = getThousandsOfLines();
flood.on('write',function(arrayOfData,bytes){
// arrayOfData is an array of the data argument to floody.write
// for all of the writes it combined into one.
});
thousandsOfLines.forEach(function(line){
process.nextTick(function(){
flood.write(format(line),1);
});
});
// when you are done
flood.stop();
// to get data on flood writes to real writes
console.log(flood.stats)
floody(stream,options)
flood.write (buffer,data)
flood.stop
flood.on
let me know if you have issues or comments. i hope its useful.