Skip to content

Instantly share code, notes, and snippets.

@iMichaelOwolabi
Last active February 8, 2022 07:40
Show Gist options
  • Save iMichaelOwolabi/43239f14d184d62db3de9c81d3c0c68e to your computer and use it in GitHub Desktop.
Save iMichaelOwolabi/43239f14d184d62db3de9c81d3c0c68e to your computer and use it in GitHub Desktop.
Sample use of blocking promise implementation in Node.js
// Do not do this since the awaits are not related in any way but are blocking ⛔️
const blockingAsnycFunction = async () => {
// Start recording the execution time of the following code.
console.time('blocking-await');
const promiseResult1 = await samplePromise1();
const promiseResult2 = await samplePromise2();
console.log(promiseResult1);
console.log(promiseResult2);
// Stop recording the execution time and log the elapsed time to the console.
console.timeEnd('blocking-await');
};
blockingAsnycFunction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment