-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync.js
More file actions
34 lines (28 loc) · 764 Bytes
/
async.js
File metadata and controls
34 lines (28 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const delay = (duration) =>
new Promise(resolve => setTimeout(resolve, duration));
let friedSteak = async() => {
console.log("start cooking steak");
await delay(2000);
console.log("steak done");
};
let washVegetable = async() => {
console.log("start washing vegetable");
await delay(500);
console.log("washing done");
};
let cookVegetable = async() => {
console.log("start cooking vegetable");
await delay(1000);
console.log("vegetable done")
};
let eat = async() => {
console.log("start enjoying dinner");
await delay(10000);
console.log("I am full. (¯√¯)");
};
async function dinner() {
await Promise.all([friedSteak(), washVegetable()]);
await cookVegetable();
await eat();
}
dinner();