Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bubble

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bubble

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

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Bubble Build Status

Domains for the poor man.

Flow-control for cascading callbacks.

Aborts groups of callbacks.

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', b(function(file_a_data) {
    fs.readFile('./file_b', b(function(file_b_data) {
      fs.readFile('./file_c', b())
    })
  }))
})

You can also leave out the timeout:

var b = bubble(function(err, file_c_data) {
  // ...
});

fs.readFile('./file_a', b(function(file_a_data) {
  // ...
});

You can also leave out the last wrapper if you're not doing more IO and don't care about the callback values:

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

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

  var file_c_data;

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

  fs.readFile('./file_a', b(function(file_a_data) {
    fs.readFile('./file_b', b(function(file_b_data) {
      fs.readFile('./file_c', function(err, value) {
        if (err) {
          // handle error
        }
        file_c_data = data;
        console.log('file ended, but bubble callback will be called anyway');
      })
    })
  }))
})

FAQs

Package last updated on 21 Mar 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc