fat-stacks
v1.0.0 queue stack sync
fat-stacks
Perform actions that need to happen in order
Manage operations that need to happen in a specific order. It also lets you collect information as the chain progresses.
var a = new Stack();
a.append(function(next) {
next({ step: 1 });
});
a.append(function(next) {
next({ step: 2 });
});
a.append(function(next) {
next({ step: 3 });
});
a.done(function() {
console.log('Done!');
});
a.run(function() {
console.log('Step Completed', data);
});
You can call next
with arguments and that gets passed over to the run
callback. You can collect data through the series.
Another useful function is the ability to pass in an error object through the stack. It will stop the stack and call an error callback:
var a = new Stack();
a.append(function(next) {
next({ step: 1 });
});
a.append(function(next) {
next({ step: 2 });
});
a.append(function(next) {
next(new Error('I just don\'t feel like doing anymore.'));
});
a.append(function(next) {
next({ step: 4 });
});
a.error(function(err) {
console.log('There was an error:', err);
});
a.done(function() {
console.log('Stack finished');
});
a.run();
npm i [email protected]
Metadata
- MIT
- Whatever
- Dustin Higginbotham
- released 1/22/2015