回答編集履歴
2
chousei
answer
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
const func2=()=>new Promise(resolve=>setTimeout(()=>resolve(2),1000));
|
4
4
|
const func3=()=>new Promise(resolve=>setTimeout(()=>resolve(3),2000));
|
5
5
|
|
6
|
-
const wrap=async(func)=>
|
6
|
+
const wrap=async(func)=>console.log(await func());
|
7
7
|
console.log("start");
|
8
8
|
Promise.all([
|
9
9
|
wrap(func1),
|
1
test
answer
CHANGED
@@ -1,1 +1,13 @@
|
|
1
|
+
```javascript
|
2
|
+
const func1=()=>new Promise(resolve=>setTimeout(()=>resolve(1),3000));
|
3
|
+
const func2=()=>new Promise(resolve=>setTimeout(()=>resolve(2),1000));
|
4
|
+
const func3=()=>new Promise(resolve=>setTimeout(()=>resolve(3),2000));
|
5
|
+
|
6
|
+
const wrap=async(func)=>{ret=await func(),console.log(ret),ret};
|
7
|
+
console.log("start");
|
8
|
+
Promise.all([
|
1
|
-
|
9
|
+
wrap(func1),
|
10
|
+
wrap(func2),
|
11
|
+
wrap(func3),
|
12
|
+
]).then(res=>console.log("end"));
|
13
|
+
```
|