bubble

Domains for the poor man. Flow-control for cascading callbacks. Error handling. Aborts groups of callbacks. With timeouts.

npm install bubble
6 downloads in the last week
6 downloads in the last month

Bubble

Aborts groups of callbacks.

Domains for the poor man.

With timeouts (if you will).

Inspired by substack/node-toss.

Example:

var bubble = require('bubble')
var timeout = 2000

require('http').createServer(function(req, res) {

  var b = bubble(timeout, function(err, file_c_data) {
    if (err) {
      res.writeHead(500)
      res.write(err.message)
    } else {
      res.end(file_c_data)
    }
  });

  fs.readFile('./file_a', h(function(file_a_data) {
    fs.readFile('./file_b', h(function(file_b_data) {
      fs.readFile('./file_c', h())
    })
  }))
})

You can also leave out the timeout:

var b = bubble(timeout, function(err, file_c_data) {
  // ...
});
npm loves you