Created
July 22, 2015 19:43
-
-
Save wearhere/4f07d298d077da9dcb2d to your computer and use it in GitHub Desktop.
What a fiber-using function looks like if you let the fiber call `done` for you. Compare https://gist.github.com/wearhere/825a51a6a16a4337733f. More info at https://www.mixmax.com/blog/node-fibers-using-synchronize-js.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processFile(fileName, done) { | |
sync.fiber(function() { | |
// No need for try-catches even, assuming that you're ok with `done` handling errors! | |
var data = /* first `sync` call */; | |
return /* second `sync` call */; | |
}, done); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment