3 ms·
>It's a good thing that async programming frameworks don't usually allow yielding from arbitrary places. Well.. await new Promise((res, rej) => { setImmed
by creatonez 7y ago
>It's a good thing that async programming frameworks don't usually allow yielding from arbitrary places.
Well..
await new Promise((res, rej) => { setImmediate(res); })
(In environments without `setImmediate` this is easily shimmed - https://github.com/YuzuJS/setImmediate https://github.com/YuzuJS/setImmediate)
- hathawsh 7y agoTrue. That's the new kind of yield that requires language support and it's only available in async functions. I was referring to what happens when framework or language designers try to allow something like the await keyword in non-async functions; it turns into an epic mess. I know because I tried (as a thought experiment.) :-)