Last active
August 29, 2015 14:03
-
-
Save kolodny/6691380b57abd5b56251 to your computer and use it in GitHub Desktop.
Simple koa like function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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