caolan/async — pull request #185 by mikeal (2012-10-04 07:30:36+00:00)
Title: Support for domains.

This patch adds support for domains to async. The test addition is purely illustrative, i have no idea how to write or run tests the way you've got em and running `npm test` appears to do nothing.

The style of support:

```javascript
if (process.domain) callback = process.domain.bind(callback)
```

Is something we discussed and established at NodeConf SummerCamp. The basic premise is that whoever owns an upper level transaction (like a web framework handling an HTTP request) will create a domain and wrap the handlers it fires for that transaction. The developer writing handlers has no idea there is a domain, and it's up to API authors (async, request, node-redis) to make sure they attach to the domain when it is active. In the case of request, it's all in an EventEmitter so it's automatically added, but for node-redis and async and other pure callback based APIs there will need to be code like this that binds the incoming callback to the domain so that any errors thrown in the handler get picked up by the transaction holder's domain.

I hope that makes sense :)