Created
May 10, 2015 08:56
-
-
Save bion/ea7ff2df7f08f1f805b6 to your computer and use it in GitHub Desktop.
async-countdown
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
| 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