async.eachSeries in node.js

后端 未结 2 1908
伪装坚强ぢ
伪装坚强ぢ 2020-12-15 08:53

I have a loop in node.js

for (var i in files){
    var all = fs.readdirsync(\"./0\");
    async.eachSeries(all, function(item){
        check(it         


        
2条回答
  •  猫巷女王i
    2020-12-15 09:15

    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 everything's done
    });
    

提交回复
热议问题