|
|
|
|
|
by jQueryIsAwesome
4826 days ago
|
|
All the code and such a big abstraction for the first example when it could have done like this: var result = [];
paths.forEach(function (i, file){
fs.stat(file, function (err, data){
result.push(data);
if (i === 0) {
// Use stat size
}
if (result.length === paths.length) {
// Use the stats
}
});
});
Fairly understandable, more efficient and without introducing logic patterns foreign to many. It also meet his requirements (It is parallel and we only hit every file once) |
|