I wonder if it could be possible to invert async/await to await/async for example:
(await () => {
let result = doSomethingWhichTakesTime();
async doSomethingElseWhichTakesTimeButDontWait(result);
waitSomeMore(100);
// This can be used as a for-await-of loop:
async for (let hello of asyncIterableStream) {
// This doSomethingTimeConsuming() function only blocks the scope
// of the for loop but doesn't block what comes after the for loop.
doSomethingTimeConsuming();
}
// The for loop above runs in parallel to this code because it was marked
// with async.
foo();
})();
Actually this would be an interesting way to solve the problem that I'm having: