Created
June 8, 2010 09:08
-
-
Save Ommadawn/429792 to your computer and use it in GitHub Desktop.
This file contains 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 help_text = []; | |
fs.readdir('help', function(err, files) { | |
if (err) throw err; | |
for(var i = 0; i < files.length; i++) { | |
fs.readFile('help/'+files[i], function(err, data) { | |
if(err) throw err; | |
help_text[file_name????] = data; | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var sys = require('sys');
var fs = require('fs');
var help_text = [];
fs.readdir('help', function(err, files) {
if (err) throw err;
for(var i = 0; i < files.length; i++) {
var a = function (m) {
fs.readFile('help/'+files[m], function(err, data) {
if(err) throw err;
help_text[files[m]] = data;
});
};
a(i);
}
});
// ici, il faudrait qu'on attende le retour de tous les callbacks de la boucle....
// comment fait-on vraiement cela... ????
setTimeout(function() {sys.puts(sys.inspect(help_text))}, 100);