Serpa (series & parallel)
Serpa is a small utility library for promise chaining.
Promises may be chained in series or parallel:
var serpa = series = serpaseries parallel = serpaparallel split = serpasplit; //Being task1, task2a, task2b and task3 functions//that either return promises for async taks//or a value, then:var work = ; //do the work ;
Series
Series execution of the tasks. The result of each task is passed to the next task.
{ return x + 2;} { var defer = qdefer; ; return defer;} var work = ; ;
Parallel
All the tasks are executed in parallel. The entry value is passed to each task.
{ return x + 2;} { var defer = qdefer; ; return defer;} var work = ; ;
Split
The tasks are executed for each element of the array that should be the input to the chain.
{ return x + 2;} { var defer = qdefer; ; return defer;} var work = ; ;
Preserve
The tasks are executed and then the original value is returned
var work = ; ;