pipex
v0.0.6
Published
simple function pipelining module that simplify the callback in nodejs
Downloads
2
Readme
pipex
About
pipex (piped executor) is simple but powerful function chaining module inspired by promise, so it has similar figure to promise, however, it provides more flexibility for callback function. and I believe it will bring us more leaner implementaion and great managability as well eventually.
- support multiple arguments for resolve / reject function
- consistant (resolve, reject) interface independent from the where the callback located.
Install
npm install pipex --save
How to use
var pipex = require('pipex');
pipex(function start(ctx){
console.log('start here and if successful call \'resolve\'');
ctx.resolve('hello');
}).then(function (ctx, val){
console.log(val);
console.log('this will print hello');
ctx.resolve(val + ' world');
}).then(function (ctx, val) {
console.log(val);
console.log('this will print hello world apparently');
ctx.resolve(val, val + ' againe');
}).then(function (ctx, val0, val1) {
console.log(val1);
console.log('this will print hello world again');
ctx.reject('hello');
}).then(function (ctx, val){
console.log('this will skipped');
}).catch(function (ctx, val){
console.log(val);
console.log('this will print hello');
}).execute();