I'm using Filewalker to traverse through a directory. However, for each file, I'd like to perform an asynchronous operation. How do I ensure that done
is fired only after all the operations are complete?
filewalker('.')
.on('file', function(p, s) {
processAsync(p);
})
.on('done', function() {
console.log('All files have been processed');
})
.walk();
As
on
file event doesn't provide any callback param, create files array and add each file to it. Then on filewalkerdone
event useasync
module to process each file asynchronously.