Answers for "nodejs parallel async calls -2"

0

nodejs parallel async calls -2

async function main() {
	// 1. 
	console.time('main')

	// 2.
	const [firstCall, secondCall, thirdCall] = await Promise.all([
		sleep(1), 
		sleep(2),
		sleep(3)
	])
	console.log(`First call: ${firstCall}`)
	console.log(`Second call: ${secondCall}`)
	console.log(`Third call: ${thirdCall}`)

	// 3.
	console.timeEnd('main')
}

main()
Posted by: Guest on September-08-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language