2 ms·
To be fair to the author, they do mention in the paragraph above that sample: Async code bubbles all the way to the top. If you want to use await, then you
by graypegg 2y ago
To be fair to the author, they do mention in the paragraph above that sample:
Async code bubbles all the way to the top. If you want to use await, then you have to mark your function as async. [...] If at any point you don’t then you have to use the async result (in JavaScript’s case a Promise<T>).
I think it's just an artificially lengthy example to show how the responsibility of working with promises grows up the callstack. Interpreting it that way since the final function they define in that sample is `iGiveUp` which is not using the async keyword, but returns a promise. Definitely could be made a bit more clear that's it's illustrative and not that the async keyword is somehow unlocking some super special runtime mode separate from it's Promise implementation.