I want to make this example https://stackoverflow.com/a/33585993/1973680 synchronous.
Is this the correct implementation?
let times= async (n,f)=>{while(n-->0) await f();}
times(5,()=>
myfunc([1,2,3],err => err)
)
myfunc is itself an async function awaiting for various other functions:
async myfunc(params,cb){
await a( err => err )
await b( err => err )
await c( err => err )
}`
Is this the correct implementation?
Yes. await works in loops like you'd expect it to, if that was your actual question.
I would however recommend to write
async function times(n, f) {
while (n-- > 0)
await f();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With