progress-pipeline
Like async.series, but with a readable-stream interface for getting progress events.
Installation
npm install progress-pipeline
Usage
var series = ;var jobs ={;}{;};;
output:
0/2 cloning ...
done cloning
1/2 installing ...
done installing
Job Functions
Jobs are regular, node-style async functions, e.g. they are being called with an error-first callback and are required to call that callback with an error and an optional result argument.
Note You can add properties to the job functions before putting them into the pipeline and you will have access to these prperties in your on('data') event handler. See demo.js for an example.
Events
You get two data
events per job
- one when the job has started
{
jobFinished: false,
job: <the job-function you provided>
jobIndex: <zero-based index of this job>
totalJobs: <total number of jobs in the pipeline>
}
- and one when the job has finished
{
jobFinished: true,
job: <the job-function you provided>
jobIndex: <zero-based index of this job>
totalJobs: <total number of jobs in the pipeline>
result: <the job's result>
}
In case a job fails, the stream emits an error
event.
The emitted error has the following additional properties:
{
job: <the job-function you provided>
jobIndex: <zero-based index of this job>
totalJobs: <total number of jobs in the pipeline>
}