visionmedia/co — pull request #55 by jonathanong (2013-11-24 20:28:52+00:00)
Title: make context and arguments be passed through thunk

this is kind of an opinionated PR and it would break compatibility (though we already broke it by removing arguments). instead of doing `co.call(gen)(args..., done)`, we now "compose" a generator function into a regular asynchronous function. so:

```js
co(function *(a, b, c) {

})
```

returns:

```js
function (a, b, c, done) {

}
```

i always thought it was weird how you call `this` and the arguments in different parts.

it would also make koa's callback simpler:

```js
app.callback = function(){
var mw = [respond].concat(this.middleware);
var done = co(compose(mw));
var self = this;

return function(req, res, next){
var ctx = self.createContext(req, res);
done.call(ctx, next || ctx.onerror);
}
};
```