I was just reading this fantastic article «Generators» and it clearly highlights this function, which is a helper function for handling generator functions:
what the heck is the difference between the
awaitkeyword and theyieldkeyword?
The await keyword is only to be used in async functions, while the yield keyword is only to be used in generator function*s. And those are obviously different as well - the one returns promises, the other returns generators.
Does
awaitalways turn something into a promise, whereasyieldmakes no such guarantee?
Yes, await will call Promise.resolve on the awaited value.
yield just yields the value outside of the generator.