# bubble

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

Latest version **0.1.0** (published 2012-03-21) · 0 weekly downloads

## Install

```sh
npm install bubble
pnpm add bubble
yarn add bubble
bun add bubble
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2012-03-21 |
| First published | 2012-03-20 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Pedro Teixeira |
| Maintainers | pgte |

## Links

- npm: https://www.npmjs.com/package/bubble
- Repository: https://github.com/pgte/bubble
- npm.io page: https://npm.io/package/bubble

## Recent versions

- 0.1.0 (latest) — 2012-03-21
- 0.0.5 — 2012-03-21
- 0.0.4 — 2012-03-20
- 0.0.3 — 2012-03-20
- 0.0.2 — 2012-03-20
- 0.0.1 — 2012-03-20

## README

# Bubble [![Build Status](https://secure.travis-ci.org/pgte/bubble.png)](http://travis-ci.org/pgte/bubble)

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:


```javascript
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:

```javascript
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:

```javascript
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');
      })
    })
  }))
})
```

---
_Source: https://npm.io/package/bubble · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
