💡 Awaited<T> (TypeScript 4.5+) recursively unwraps Promise types. Awaited<Promise<Promise<string>>> = string. This is used by ReturnType when dealing with async functions — Awaited<ReturnType<typeof asyncFn>> gives you the resolved value type.
📸 Verified Output:
Step 2: Parallel vs Sequential Execution
💡 Promise.all vs Promise.allSettled:Promise.all rejects immediately if ANY promise rejects (fail-fast). Promise.allSettled waits for ALL promises and gives you both fulfilled and rejected results. Use allSettled when you need to process all results even if some fail.
📸 Verified Output:
Step 3: Async Generators & Iterators
💡 async function* + for await...of is the TypeScript way to process lazy async sequences — database cursors, API pagination, file streams, WebSocket messages. The generator pauses at each yield until the consumer is ready for the next item, creating natural backpressure.