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.
Supports promises and callbacks.
The Basics
npm install stream-worker
Requiring:
var streamWorker = ;
Promise style:
{ /* ... do some work with data ... */ return Promise;}
Callback style:
{ /* ... do some work with data ... */ return ;;};
Signature
streamWorker(stream, work, options, done)
Where options is an object with 2 optional parameters:
Parameter | Default | Description |
---|---|---|
promises | false | true if you want to use the above promises style |
concurrency | 10 | specifies how many concurrent workers you want doing work in the stream |
And done is a callback function if you use the callback workflow.