Skip to content

Instantly share code, notes, and snippets.

@bschwind
Created September 1, 2015 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bschwind/ed5aeb98636b68d2103d to your computer and use it in GitHub Desktop.
Save bschwind/ed5aeb98636b68d2103d to your computer and use it in GitHub Desktop.
readFile("filename.txt", function(err, data) {
console.log("5 seconds have elapsed");
if (err) { return; }
readFile("otherfile.txt", function(err, data) {
console.log("10 seconds have elapsed");
if (err) { return; }
writeFileToNetwork(data, function(err, response) {
if (err) { return; }
console.log("complete");
});
});
});
readFile("otherfile.txt", function(err, data) {
console.log(data);
});
readFile("filename.txt")
.then(function (data) {
console.log(data);
return readFile("otherfile.txt");
})
.then(function (otherData) {
console.log(otherData);
return writeFileToNetwork(otherData);
})
.then(function (response) {
console.log("complete");
})
.catch(function (err) {
console.error(err);
});
// var data = readFile("filename.txt"); - 5 secs
// var otherFile = readFile("otherfile.txt"); - 5 secs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment