It's going to be an even bigger hit than express, for sure.
#!/usr/bin/env node --harmony
var fs = require('fs'),
co = require('co'),
thunkify = require('thunkify'),
request = require('request'),
readFile = thunkify(fs.readFile);
get = thunkify(request.get);
var log = console.log.bind(console);
// Create a thunk, and run it immediately.
co(function *(){
try {
var fileContents = yield readFile('myfile', 'utf8');
log(fileContents);
var yahoo = (yield get('http://yahoo.com'))[0];
log(yahoo.statusCode)
} catch(error) {
log('Oh no, an error!')
log(error.code)
}
})()
Async, inline, catching errors. It's nice.You can start throwing that on mocha too, it's pretty sweet.