
Show HN: New async JavaScript paradime with async generator and async iteration - brn27
https://github.com/brn/sagu
======
theprotocol
Is the main addition here the scoping of the awaited response? Am I missing
something else?

In ES6+ `try/catch` already offers similar scoping, albeit without the
destructuring of the result being a part of the syntax (you declare the
response, preferably as a `const`, at the top of the try/catch block).

~~~
brn27
No, scoping is not a matter. Most important things in here is that you can
treat async callback or async repeatation as normal for-await-of loop. Async
callback function is no loger necessary any more in javascript.

~~~
theprotocol
Oh. This is interesting. Is the `for await` loop synchronous, or is more like
looping through the results of `Promise.all`? With Promise.all, you can make
multiple async concurrently and then await the results once all of them are
complete.

~~~
brn27
for-await loop behavior is bit complex, but roughly, it's like async await
functionality. So, for-await loop wait promise step by step, and if await
keyword exists in loop body, wait too. So it's looks like synchronous from
inside of async function, but behave as asynchronous promise at outside of
async function.

