Last active
April 17, 2017 21:38
-
-
Save retrohacker/25d1c53ec48cc19bae80c7a05cfbc2d4 to your computer and use it in GitHub Desktop.
async-order
This file contains hidden or 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 loadFile() { // 1 | |
fs.readFile('./foobar.txt', 'utf8', saveFile); // 5 | |
} | |
function saveFile(e, contents) { // 2 | |
if(e) { // 6 | |
// Stop executing function, we encountered an error | |
return console.error(e); // 7 | |
} // 8 | |
fs.saveFile('./buzzbazz.txt', 'utf8', done); // 9 | |
} | |
function done(e) { // 3 | |
if(e) { // 10 | |
return console.error(e); // 11 | |
} // 12 | |
} | |
loadFile(); // 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment