Skip to content

Instantly share code, notes, and snippets.

@Raynos Raynos/x.js Secret
Created Aug 6, 2013

What would you like to do?
var main = suspend(function* (resume) {
var c1 = yield http.get('',
var c2 = yield http.get('',
// 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 =;
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
You can’t perform that action at this time.