1.0.1 • Published 10 years ago

fat-stacks v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
10 years ago

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();
1.0.1

10 years ago

1.0.0

10 years ago