0.2.0 • Published 8 years ago
promise-circuit v0.2.0
promise-circuit
Create a circuit-type flow for Promise functions.
Create a series of Promise-returning functions (with prepared arguments):
const foo = new Circuit();
for (let item of something) {
foo.add(myFn, [item, -item]);
}
foo.run().then(results => {
// ...
});
Installation
$ npm install --save promise-circuit
Usage
import Circuit from 'promise-circuit';
new Circuit([series])
Create a circuit.
series
(Array
): Pre-provided series.
Series format:
new Circuit([[fn, args], [fn, args]]);
Circuit#add(fn, [args])
Add a promise function to the circuit.
fn
(function
): A promse-returning (or thenable) function.args
(Array
): Arguments to be passed in once the circuit is ran.
Circuit#run()
Run the series of promise functions in a circuit-like flow.
Returns Promise
with all the results of the circuit.
Credits
Jamen Marzonie |
0.2.0
8 years ago