Skip to content

Instantly share code, notes, and snippets.

@CrabDude
Created September 25, 2013 15:50
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 CrabDude/6701694 to your computer and use it in GitHub Desktop.
Save CrabDude/6701694 to your computer and use it in GitHub Desktop.
function* foo() {
// Parallel calls with no helper lib
var paths = ['A.js', 'B.js']
var group = []
for (path in paths) {
group.push(fs.readFile(path))
}
var files = yield group
// Serial calls
var filesTwo = yield fs.readFile(files[0])
}
run(function*() {
// try/catch works across ticks
try {
var value = yield* foo(argOne)
} catch(e) { … }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment