我需要递归读取文件来计算文件夹中的单词,我怎么知道何时以异步结束? 它与Node - how to wait on async operations?
不同function loop_file(folder) {
fs.readdir(folder, function (err, files) {
files.forEach(function (file) {
var abs_path = path.join(folder, file);
fs.stat(abs_path, function (err, stat) {
if (stat.isDirectory()) {
loop_file(abs_path)
} else if (stat.isFile()) {
//proceess ???
}
})
})
});
}