Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wearhere/cb4c4145cf4bdbbdea14 to your computer and use it in GitHub Desktop.
Save wearhere/cb4c4145cf4bdbbdea14 to your computer and use it in GitHub Desktop.
Asynchronous functions should create their own fibers. More info at https://www.mixmax.com/blog/node-fibers-using-synchronize-js.
function processFile(fileName, done) {
sync.fiber(function() {
var data = sync.await(fs.readFile(fileName, sync.defer()));
return /* do something with the data */;
}, done);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment