stream-worker

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

npm install stream-worker
6 downloads in the last day
30 downloads in the last week
118 downloads in the last month

stream-worker build status

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

The Basics

npm install stream-worker

then

var streamWorker = require('stream-worker');

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

Signature

streamWorker(stream, concurrencyLimit, work, done)

npm loves you