Skip to content

Instantly share code, notes, and snippets.

@hokaccha
Created April 4, 2013 03:54
Show Gist options
  • Save hokaccha/5307697 to your computer and use it in GitHub Desktop.
Save hokaccha/5307697 to your computer and use it in GitHub Desktop.
function coro(f) {
var g = f(function(x) { g.send(x) });
g.next();
}
function wait(ms, next) {
setTimeout(function() {
next('bar');
}, ms);
}
coro(function(next) {
console.log('foo');
var res = yield wait(1000, next);
console.log(res);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment