Skip to content

Instantly share code, notes, and snippets.

@elrrrrrrr
Created November 21, 2014 04:22
Show Gist options
  • Save elrrrrrrr/4eb0fdadc59b2045e192 to your computer and use it in GitHub Desktop.
Save elrrrrrrr/4eb0fdadc59b2045e192 to your computer and use it in GitHub Desktop.
simple-co
function co(generator) {
return function(fn) {
var gen = generator();
function next(err, result) {
if(err){
return fn(err);
}
var step = gen.next(result);
if (!step.done) {
step.value(next);
} else {
fn(null, step.value);
}
}
next();
}
}
module.exports = co;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment