Skip to content

Instantly share code, notes, and snippets.

@bion
Created May 10, 2015 08:56
Show Gist options
  • Select an option

  • Save bion/ea7ff2df7f08f1f805b6 to your computer and use it in GitHub Desktop.

Select an option

Save bion/ea7ff2df7f08f1f805b6 to your computer and use it in GitHub Desktop.
async-countdown
var fs = require('fs');
var files = fs.readdirSync("./test");
var everybody = "";
var doneCount = files.length;
var i;
for (i = 0; i < files.length; ++i) {
fs.readFile("./test/" + files[i], function(err, data) {
if (err != null) throw new Error(err);
everybody += data;
if (--doneCount === 0)
console.log(everybody);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment