const arr: number[] = [1, 2, 3, 4, 5];
const result: number[] = await Promise.all(arr.map(async (elem): Promise<number> => {
await asyncFunction();
return elem + 10;
}));
// result === [11, 12, 13, 14, 15]
const arr = [1, 2, 3];
const asyncRes = await Promise.all(arr.map(async (i) => {
await sleep(10);
return i + 1;
}));
console.log(asyncRes);
// 2,3,4
Arr = await Promise.all(arr)
const arr = [1, 2, 3];
const syncRes = arr.map((i) => {
return i + 1;
});
console.log(syncRes);
// 2,3,4