Skip to content

Instantly share code, notes, and snippets.

@Ommadawn
Created June 8, 2010 09:08
Show Gist options
  • Save Ommadawn/429792 to your computer and use it in GitHub Desktop.
Save Ommadawn/429792 to your computer and use it in GitHub Desktop.
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;
});
}
});
@peutetre
Copy link

peutetre commented Jun 8, 2010

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment