"Promise.all 이 tuple 보존하는 parallelism."
Promise.all 이 뭐 함
Promise.all([p1, p2, p3]) 가 Promise 배열 (또는 tuple) 받고 모든 입력 Promise resolve 될 때 resolve 하는 Promise 반환. Resolved 값이 같은 순서의 resolved 값 배열.
타입 레벨에서, tuple 전달하면 결과가 tuple 모양 보존: Promise.all([Promise.resolve(1), Promise.resolve('a')]) 가 Promise<[number, string]>. 즉 await 후 destructuring 이 각 위치 타입 보존 — `[a, b]` 가 `a: number; b: string` 얻음.
순차 vs 병렬
연속 두 await 호출이 순차 실행. const a = await fa(); const b = await fb() 가 time(fa) + time(fb) 걸림. Promise.all 이 병렬: const [a, b] = await Promise.all([fa(), fb()]) 가 max(time(fa), time(fb)) 걸림.
독립 async 호출엔 Promise.all 이 거의 항상 옳은 수. Compiler 가 너의 호출이 독립인지 알 수 없어 — 그게 너의 일.
실패 행동
Promise.all 이 빨리 reject: 어떤 입력 Promise 든 reject 하면 전체가 그 에러로 reject. '모두 기다리고, 성공과 실패 둘 다 수집' 엔 `Promise.allSettled` 써 (`{ status: 'fulfilled' | 'rejected', value? / reason? }` 배열 반환).