无法返回最终值async.map

时间:2014-08-08 03:46:49

标签: javascript asynchronous async.js

我试图返回async.map的最终值,而不是console.logging。不幸的是,return语句永远不会运行:

var square = function (num, doneCallback) {
  return doneCallback(null, num * num);
};
// **Works**
async.map([1, 2, 3, 4], square, function (err, results) {

  console.log("Finished!");
  console.log(results);
  // return results;
});


// **Not Working**
async.map([1, 2, 3, 4], square, function (err, results) {

  console.log("Finished!");
  // console.log(results);
  return results;
});

我如何return结果而非使用console.log

0 个答案:

没有答案