回答編集履歴

2

chousei

2020/11/26 11:17

投稿

yambejp
yambejp

スコア116661

test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- const wrap=async(func)=>{ret=await func(),console.log(ret),ret};
11
+ const wrap=async(func)=>console.log(await func());
12
12
 
13
13
  console.log("start");
14
14
 

1

test

2020/11/26 11:17

投稿

yambejp
yambejp

スコア116661

test CHANGED
@@ -1 +1,25 @@
1
+ ```javascript
2
+
3
+ const func1=()=>new Promise(resolve=>setTimeout(()=>resolve(1),3000));
4
+
5
+ const func2=()=>new Promise(resolve=>setTimeout(()=>resolve(2),1000));
6
+
7
+ const func3=()=>new Promise(resolve=>setTimeout(()=>resolve(3),2000));
8
+
9
+
10
+
11
+ const wrap=async(func)=>{ret=await func(),console.log(ret),ret};
12
+
13
+ console.log("start");
14
+
15
+ Promise.all([
16
+
1
- こういうことでしょうか?
17
+ wrap(func1),
18
+
19
+ wrap(func2),
20
+
21
+ wrap(func3),
22
+
23
+ ]).then(res=>console.log("end"));
24
+
25
+ ```