当我尝试使用when.js并行函数时,我有点难以理解我可能做错了什么:
https://github.com/cujojs/when/blob/master/docs/api.md#whenparallel
var parallel = require('when / parallel');
var resultsPromise = parallel(arrayOfTasks,arg1,arg2 / *,... * /);
据我所知,arrayOfTasks可以是一个Promises数组?但是当我尝试用这样的并行替换when.all时,我遇到了错误“TypeError:task.apply不是函数”:
var when = require('when');
var parallel = require('when/parallel');
var arrayOfPromises = [
when.resolve('a'),
when.resolve('b'),
when.resolve('c'),
];
return parallel(arrayOfPromises)
.then(function(parseResultArray) {
console.log("result", parseResultArray);
});