Skip to content

Instantly share code, notes, and snippets.

@Raynos

Raynos/x.js Secret

Created August 6, 2013 00:54
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 Raynos/cd56289abb847cc62b2d to your computer and use it in GitHub Desktop.
Save Raynos/cd56289abb847cc62b2d to your computer and use it in GitHub Desktop.
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