javascript – async.eachSeries in node.js
javascript – async.eachSeries in node.js
Assuming check
accepts a callback, we can use mapSeries
to achieve that.
async.mapSeries(files, function(file, outerCB) {
var all = fs.readdirsync(./0);
async.mapSeries(all, function(item, cb){
check(item, cb);
}, outerCB);
}, function(err, results) {
// This is called when everythings done
});
Outer loop needs to be async also. One of the the methods is to use 2 eachSeries loops or outer loop can be in parallel (each) if the files dont have to be processed in series:
var async = require(async);
async.eachSeries(files, function(file, outCb)
{
var all = fs.readFileSync(file);
async.eachSeries(all, function(item, inCb)
{
check(item);
inCb(null); // inner callback
},
function(err)
{
outCb(null); // outer callback
});
},
function(err)
{
console.log(all done!!!);
});
javascript – async.eachSeries in node.js
Related posts on java script :
- What is pseudo classical inheritance in JavaScript?
- What does shift () method in JavaScript?
- How do I remove a word in JavaScript?
- How do I strip spaces in JavaScript?
- What does .slice do in JavaScript?
- How do I put JavaScript in HTML?
- Does JavaScript support optional chaining?
- Should I disable JavaScript on Safari?
- Are Java and JavaScript are same?