Create a gist now

Instantly share code, notes, and snippets.

@kolodny /run.js
Last active Aug 29, 2015

What would you like to do?
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