visionmedia/co — pull request #71 by hrsh7th (2014-01-03 23:20:17+00:00)
Title: add optional context.

Want to change generator-function context without invoke.
Please see following example:

```javascript
var request = require('co-request');
var thunk = require('thunkify');
var fs = require('fs');

fs.writeFile = thunk(fs.writeFile);

function Downloader(uri, dist) {
this.uri = uri;
this.dist = dist;
this.statusCode = undefined;
this.body = undefined;
}

Downloader.prototype.load = function (){
return co(function *(){
var res = yield request({ uri: this.uri });
this.statusCode = res.statusCode;
this.body = res.body;
}, this);
};

Downloader.prototype.save = function (){
return co(function *(){
if (this.statusCode !== 200) throw new Error('download not success.');
yield fs.writeFile(this.dist + '/' + this.uri, this.body);
}, this);
};

co(function *(){
var downloader = new Downloader('http://google.com', '/dist');
yield downloader.load();
yield downloader.save();
console.log('success.');
});

```

Example using currently co:

```javascript
var request = require('co-request');
var thunk = require('thunkify');
var fs = require('fs');

fs.writeFile = thunk(fs.writeFile);

function Downloader(uri, dist) {
this.uri = uri;
this.dist = dist;
this.statusCode = undefined;
this.body = undefined;
}

Downloader.prototype.load = function (){
var self = this;
return co(function *(){
var res = yield request({ uri: self.uri });
self.statusCode = res.statusCode;
self.body = res.body;
});
};

Downloader.prototype.save = function (){
var self = this;
return co(function *(){
if (self.statusCode !== 200) throw new Error('download not success.');
yield fs.writeFile(self.dist + '/' + self.uri, self.body);
});
};

co(function *(){
var downloader = new Downloader('http://google.com', '/dist');
yield downloader.load();
yield downloader.save();
console.log('success.');
});

```