Skip to content

Contains examples to understand how asynchronism works in JavaScript

Notifications You must be signed in to change notification settings

dfbq91/asynchronism

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Asynchronism 👋

Version Twitter: diegobtancourt

Contains examples to understand how asynchronism works in JavaScript

Files Description

asynchronism.js

Contains one function written with callbacks, promises and async-await. It was done based on this video tutorial of Asynchronism

sequential

There are two files in this folder.

tasks.js

Contains two functions. These functions are simple, their objective is just to prove sequential asynchronism.

index.js

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

pararell

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

Author

👤 Diego Betancourt

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator

About

Contains examples to understand how asynchronism works in JavaScript

Topics

Resources

Stars

Watchers

Forks