Async programming
This part follows callbacks into promises: the three states of a promise, async and await, Promise.all and Promise.race, an HTTPS client, AbortController and the errors of async code. The part ends with sequential against parallel work and with the event loop underneath both.
8.1
Callbacks to promises
nested callbacks turned into promises, and a chain that stays flat
Open
8.2
Promises
the three states, a promise built by hand, and then chained into one catch
Open
8.3
async and await
async and await, and error handling that reads like plain code
Open
8.4
Promise.all
many promises at once, one failure, and a list mapped into calls
Open
8.5
Promise.race
the first promise to settle, a timeout built on it, and when racing fits
Open
8.6
HTTPS client
text and JSON over HTTPS with the built-in module and typed promises
Open
8.7
Abort and timeouts
AbortController, a timer that cancels, and the cleanup on both paths
Open
8.8
Async error handling
a throw through await, a local catch, a guard, and a retry with backoff
Open
8.9
Sequential vs parallel
tasks in order against tasks at once, and a batch that caps concurrency
Open
8.10
Event loop
how the loop orders promises and timers, and what keeps it responsive
Open