pyd
Run pyramid structures in Node.JS via the simple way.
Overview
For example, if you have three functions that must be called in a pyramid structure:
//Function1{ /* do something */ return ; } //Function2{ /* do something */ return ; } //Function3{ /* do something */ return ; }
pyd will transform the following pyramid structure:
{ //Run the first function ;}
On this:
//Import pydvar pyd = ; { //Create the new pyramid var p = ; //Concatenate the three functions pstartFunction1; //Last call p; //Run the pyramid p;}
API
p.start(function)
Defines the first function to run on the pyramid. The argument must be a function that gets two arguments:
value
: the value with the function will be called. For multiple arguments, you must use an object.callback
: a function to call the next function on the pyramid. You must give the value that will be used as argument for the following function.
p.then(function)
Set the next function to run in your pyramid. You can set all functions as you need. The argument must be the same as described in the p.start
method.
p.end(function)
Set the last function to execute in the pyramid. On this case, the argument must be a function that will be called with the last value generated on the pyramid.
p.run(value)
Run the pyramid. The argument must be a value that will be used as the value for the first function on the pyramid.
Examples
You can find examples using the pyd module on the examples
folder.
License
Under the MIT LICENSE.