Answers for "async await map"

0

async map js

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
Posted by: Guest on August-22-2021
0

async await map

var arr = [1, 2, 3, 4, 5];

var results: number[] = await Promise.all(arr.map(async (item): Promise<number> => {
    await callAsynchronousOperation(item);
    return item + 1;
}));
Posted by: Guest on October-21-2021
0

async map js

const arr = [1, 2, 3];

const syncRes = arr.map((i) => {
	return i + 1;
});

console.log(syncRes);
// 2,3,4
Posted by: Guest on August-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language