Skip to content

Instantly share code, notes, and snippets.

@wearhere
Last active August 29, 2015 14:25
Show Gist options
  • Save wearhere/187ab0475b8db0f2313c to your computer and use it in GitHub Desktop.
Save wearhere/187ab0475b8db0f2313c to your computer and use it in GitHub Desktop.
Fiber-using code after refactoring, take 1. More info at https://www.mixmax.com/blog/node-fibers-using-synchronize-js.
sync.fiber(function() {
var processedData = processFile('a.txt');
});
function processFile(filename) {
var data = sync.await(fs.readFile(fileName, sync.defer()));
return /* do something with the data */;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment