I have some piece of asynchronous code which is currently being executed one by one. I understand there is a way to execute this in parallel but couldn't find out the syntax to do. this is how it looks at the moment
async function someAsyncFunc(i) {
await wait(i);
return i;
}
async function wait(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}
function doSomething() {
const arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000];
arr.forEach(item => {
someAsyncFunc(item)
.then(res => {
console.log(res);
})
});
console.log("finished");
}
doSomething();
Any help will be really appreciated.