In my current code, I am using a for loop structured like this:
async myFunc() {
for (l of myList) {
let res1 = await func1(l)
if (res1 == undefined) continue
let res2 = await func2(res1)
if (res2 == undefined) continue
if (res2 > 5) {
... and so on
}
}
}
The issue here is that func1 and func2 are network calls that return promises, and I don't want them to slow down my for loop while waiting for their completion. I'm open to processing myList[0] and myList[1] concurrently, and I don't have a preference for the order in which the list items are handled.
How can I modify my code to achieve this parallel processing?