how do I use generator to achieve the following functions?
function f1(){
return new Promise((resolve,reject) =>{
setTimeout(() =>{
resolve(1);
},1000)
})
}
function f2(value){
return new Promise((resolve,reject) =>{
setTimeout(() =>{
resolve(value + 2);
},1000)
})
}
function f3(value){
return new Promise((resolve,reject) =>{
setTimeout((value) =>{
resolve(value + 3);
},1000)
})
}
const foo = async () =>{
let result_1 = await f1();
let result_2 = await f2(result_1);
let result_3 = await f3(result_2);
return result_3;
}
foo();
Thank you for your reply!