Contains examples to understand how asynchronism works in JavaScript
Contains one function written with callbacks, promises and async-await. It was done based on this video tutorial of Asynchronism
There are two files in this folder.
Contains two functions. These functions are simple, their objective is just to prove sequential asynchronism.
In this file, the tasks.js functions are imported. In this file I make the time measurement of taskOne and taskTwo functions, the duration of taskOne is four seconds and taskTwo is two seconds. Therefore, if there are no errors, the execution time should be about 6 seconds (taskOne + taskTwo). If an error occurs, for example, in taskOne, the execution time should be 2 seconds. Therefore, task Two is executed after task One is finished.
Run: node index.js
It contains the same files as the sequential folder. Its purpose is to test
sequential asynchronism.
The difference is the code of the index.js file. I used Promise.all() to run taskOne and
taskTwo at the same time. Therefore, the time measurement should be 4 seconds (the time of
longer function)
Run: node index.js
👤 Diego Betancourt
- Website: https://www.linkedin.com/in/diegofernandobetancourtquintero/
- Twitter: @diegobtancourt
- Github: @dfbq91
- LinkedIn: @diegofernandobetancourtquintero
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator