Pita/async-stacktrace — pull request #2 by prust (2013-03-02 07:16:31+00:00)
Title: Added callback-wrapping feature

@Pita: I'm not sure if you're interested in this feature, but it will be useful to us, so I thought I would open a pull request as an FYI.

Occasionally in our code base it is convenient to pass the callback function along directly, without wrapping it in another anonymous function -- for instance in situations like this:

```js
function getUsers(db, callback) {
var sql = 'SELECT * FROM users';
db.query(sql, callback);
}
```

In order to use `ERR()`, we would have to add an anonymous function, like this:

```js
function getUsers(db, callback) {
var sql = 'SELECT * FROM users';
db.query(sql, function(err, data) {
if (ERR(err, callback)) return;
callback(null, data);
});
}
```

This pull request allows us to instead wrap the callback with `ERR()`, like this:

```js
function getUsers(db, callback) {
var sql = 'SELECT * FROM users';
db.query(sql, ERR(callback));
}
```

The stacktrace line is cached at the moment of wrapping and re-used later if an error object is passed to the wrapped callback function.

I added a couple of tests and some documentation. Thanks for your work on this project!