Makes async programming manageable (dare I say delightful?) without wasting horizontal space.
Steps is a simple way to manage a few of the most common async programming problems in a more readable way. Basic ideas:
Behold: this mess
var filesModified = ;fs;
steps = ;var filesModified = ;;
If you are a coffeescripter, the code looks even nicer.
There are only a few functions to remember:
This function simply returns an object with our other API calls attached. Behind the scenes,
it instantiates a new object for us to use throughout an async session.
steps().sequence(fn1, [fn2, [fn3, ... [fnN]]])
This function executes a series of functions in sequence. In each case the next function is
fired when the current function calls
this.step.next. Any information passed to
will be forwarded to the next function's arguments.
steps().parallel(fn2, [fn2, [fn3, ... [fnN]]])
This function executes all the listed functions immediately. Once each function calls
the process will end and the callback will be fired. Data passed to
this.step.done will be collected
into an array in the order the functions were listed (not in the order of execution).
In this function,
fn will execute for each item in the collection (be it an object or array).
this.step.done is called for each item, the process completes and the callback is fired.
This function will be called on success of the entire process.
This function will be called on error.