-
-
Save Raynos/cd56289abb847cc62b2d to your computer and use it in GitHub Desktop.
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
var main = suspend(function* (resume) { | |
var c1 = yield http.get('http://gist.github.com/isaacs/6143332', | |
resume.raw()) | |
var c2 = yield http.get('http://gist.github.com/isaacs/6093040', | |
resume.raw()); | |
// Get the stream - its the first argument | |
var s1 = c1[0], s2 = c2[0]; | |
var ready, select = selector([s1, s2]); | |
var finished = 0; | |
while (ready = yield select(resume)) { | |
var which = ready == s1 ? 's1':'s2'; | |
var data = ready.read(); | |
var file = yield fs.readFile(data, resume) | |
console.log(which, data && data.length, file); | |
if (!data) | |
if (++finished < 2) continue; | |
else break; | |
} | |
console.log("All done!"); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment