uses syntax similar to express middlewares, but outside the context of webapps
npm i bamba
var bamba = require('bamba')
bamba(function (context, next) {
// do something with context
next(); // call next when you're done. alternatively, return a promise
}, function (context, next) {
// modifications on context are available in the next function
if ( context.error ){
next('got an error'); // pass error. this will reach the next function with error
} else {
next(); // simply moves to next function
}
}, function( context, next ){
// if the previous function passed an error, we will skip this one
next();
},function (err, context, next) {
// this function will be invoked if there was an error, and if there was no error
// it allows you to handle the error and move on
}, ... )