From the course: Advanced Node.js

Unlock the full course today

Join today to access over 23,500 courses taught by industry experts.

Parallel execution

Parallel execution - Node.js Tutorial

From the course: Advanced Node.js

Parallel execution

“

- [Narrator] In the last few lessons, we discussed sequential execution. But promises also come with some functions that allow us to resolve them at the same time. We can make a bunch of asynchronous requests at once and obtain a series of asynchronous results faster, because these requests will not have to execute in order, or wait for the previous request to be completed. When we're resolving several promises at the same time, it's referred to as parallel execution. Let's go ahead and take a look at our sample. Now we still have some of the same code that we created in the last few lessons. Using the file system and promise of file utility, we've created promises for writeFile, unlink, and readdir. We also have a beep function on line six that will cause a beep to occur, and then we have a delay function that will return a custom promise that will wait for a certain number of seconds. We can create a single promise that will resolve several promises at once using promise.all. So…

Contents