async-parts
v0.2.1var Async = require('async-parts');
// next()-chained async tasks
(new Async)
.catch(function(err, next) {
if (err) {
console.log(err);
}
next();
})
.then(function(next) {
next(/* error, data, ... */);
// or throw new Error(...)
})
.run(function(err, data) {
// err will be empty on success
// data will be collected from next()
});
Usage
new Async(context)
will expose three methods:
- catch(handler) — Error handler for the chain
- then(handler) — Adds a subtask to chain
- run(success) — Initialize the chain
The created chain will be consumed until there are no more subtasks to invoke.
The constructor function can accept a context that will be bound on each callback.
Async.queue()
is deprecated since 0.2.0
.
npm i [email protected]
Metadata
- MIT
- Whatever
- Alvaro Cabrera
- released 12/2/2014