Skip to content

Instantly share code, notes, and snippets.

@retrohacker
Last active April 17, 2017 21:38
Show Gist options
  • Save retrohacker/25d1c53ec48cc19bae80c7a05cfbc2d4 to your computer and use it in GitHub Desktop.
Save retrohacker/25d1c53ec48cc19bae80c7a05cfbc2d4 to your computer and use it in GitHub Desktop.
async-order
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