Skip to content

Instantly share code, notes, and snippets.

@i-van
Created October 31, 2014 11:37
Show Gist options
  • Save i-van/09349abbf2f19047fb84 to your computer and use it in GitHub Desktop.
Save i-van/09349abbf2f19047fb84 to your computer and use it in GitHub Desktop.
var async = require('asyncawait/async'),
await = require('asyncawait/await'),
fs = require('fs');
function read(path) {
return function(done) {
fs.readFile(path, 'utf8', done);
}
}
Function.prototype.await = function() {
return await(this);
};
var fn = async.cps(function() {
return read(__filename).await().length;
//return await(read(__filename)).length;
});
fn(function(err, res) {
err && console.log(err);
console.log(res);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment