UNPKG

atbar

Version:

Async callback manager for javascript in nodejs and browser

36 lines 972 B
/* coffee -cb /opt/node/bb/dev/node_modules/atbar/atbar.cof coffee -cb /opt/node/bb/dev/node_modules/atbar/tests/arg-error.cof */var atbar, badFunc; var __slice = Array.prototype.slice; atbar = require('atbar'); atbar.options = 'trace'; badFunc = function(cb, bad) { return setTimeout(function() { if (bad) { return cb('I am an error msg', null); } else { return cb(null, 'I am good results data'); } }, 2000); }; atbar.run(function() { this._(function() { return badFunc(this.$(), false); }); this._(function(_err, resp) { console.log('resp: ' + resp); return this.$()(); }); this._(function() { return badFunc(this.$(), true); }); return this._(function(_err, resp) { console.log('should not see this' + resp); return this.$()(); }); }, function() { var args; args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; return console.log('atbar final callback: ' + JSON.stringify(args)); });