Skip to content

Instantly share code, notes, and snippets.

@armed
Last active January 2, 2016 19:39
Show Gist options
  • Save armed/8352133 to your computer and use it in GitHub Desktop.
Save armed/8352133 to your computer and use it in GitHub Desktop.
var fs = require('fs');
var files = ['file1.txt', 'file2.txt', 'file3.txt', 'file4.txt'];
var fileData = {};
files.forEach(funcion (name, index) {
fs.readFile(nam, function (err, data) {
if (err) {
console.log('Error:', err);
}
fileData[name] = data;
if (index === files.length - 1) {
processFiles();
}
});
});
function processFiles() {
// work with files
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment