stream-worker

Execute an async function per stream data event, pausing the stream when a concurrency limit is saturated

stream-worker

Execute an async function per stream data event, pausing the stream when a concurrency limit is saturated. Inspired by async.queue, optimized for streams.

npm install stream-worker

then

var streamWorker = require('stream-worker');
 
streamWorker(stream, 10, 
  function(datadone) { 
    /* ... do some work with data ... */ 
    done(err);
  }, 
  function(err) { 
    /* ... the stream is exhauseted and all workers are finished ... */ 
  }
);

streamWorker(stream, concurrencyLimit, work, done)