我真的需要两者吗?
不能。使用promises在集合上映射异步迭代器非常简单,但是它需要两个步骤而不是一个函数调用。首先,集合
mapPED以承诺为并行迭代的阵列。然后,将这些承诺输入到
Q.all映射集合的一个承诺中。与相比
async,结果的顺序得到保证。
var entries = […]; // some array of objects with "id" attributesvar promises = entries.map(function(object) { return asyncPromiseReturingFunction(object);}); // the anonymous wrapper might be omittedreturn Q.all(promises);对于
concat,您必须附加一个
.then(function(results) { return Array.prototype.concat.apply([], results);});


