Skip to content

Instantly share code, notes, and snippets.

@kolodny
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kolodny/6691380b57abd5b56251 to your computer and use it in GitHub Desktop.
Save kolodny/6691380b57abd5b56251 to your computer and use it in GitHub Desktop.
Simple koa like function
function run(gen) {
step();
function step(value) {
var result = gen.next(value);
if (result.value instanceof Promise) {
result.value.then(step);
} else if (result.value instanceof Array) {
Promise.all(result.value).then(step);
} else if (!result.done) {
step(result.value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment