Last active
August 29, 2015 14:25
-
-
Save wearhere/825a51a6a16a4337733f to your computer and use it in GitHub Desktop.
What a fiber-using function would look like if you called `done` rather than letting the fiber do it for you. Compare https://gist.github.com/wearhere/4f07d298d077da9dcb2d. 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() { | |
var data; | |
try { | |
data = /* first `sync` call */; | |
} catch(e) { | |
done(e); | |
return; | |
} | |
var processedData; | |
try { | |
processedData = /* second `sync` call */; | |
done(null, processedData); | |
} catch(e) { | |
done(e); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment