sách gpt4 ăn đã đi

javascript - async.each 和 async.eachSeries 之间的区别

In lại 作者:数据小太阳 更新时间:2023-10-29 04:01:53 38 4
mua khóa gpt4 giày nike

async.each 是否作为异步数组迭代工作?

async.eachSeries 是否作为同步数组迭代工作?(它实际上等待响应)

我问这些是因为两者都有回调,但 async.each 的工作方式类似于 ex 的异步数组迭代:

//This is traditional way to iterate an array with callback functions in node.js
//Is this same with async.each ? i want to know it actually.

for (var i = 0; i < data.length; i++) {
(function (i) {
request(data[i],function(body){
console.log(body)
});
})(i);

//if this codes and async.each are doing same things ,
//i know that async gives me an aert when all finished thats the difference.

câu trả lời hay nhất

您的代码示例与 async.each 所做的最相似,因为所有异步 lời yêu cầu 调用都是立即进行的,并允许并行进行。

async.eachSeries 的不同之处在于,每次迭代都会等待异步操作完成,然后再开始下一个操作。

关于javascript - async.each 和 async.eachSeries 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35258277/

38 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress