The Promise API is small but each combinator has a precise rule for when it
fulfills and when it rejects, and choosing the wrong one causes silent data loss
or unhandled rejections. This reference lists every Promise method with its
settlement rule and the equivalent async/await pattern.
How it works
A Promise is in one of three states: pending, fulfilled, or rejected. Instance methods register callbacks:
then(onFulfilled, onRejected)transforms the value or handles rejection.catch(onRejected)is shorthand forthen(undefined, onRejected).finally(onFinally)runs on either outcome and passes the result through.
The static combinators take an iterable of promises and differ only in their settlement rule:
Promise.all // fulfills with all values; rejects on first rejection
Promise.allSettled // never rejects; array of {status, value|reason}
Promise.any // first fulfillment; AggregateError if all reject
Promise.race // first to settle, fulfill OR reject, wins
Tips
Use all when you need every result and any failure should abort the batch;
use allSettled when partial failure is fine and you want to inspect each
outcome. Reach for any to get the first success across redundant sources, and
race to enforce a timeout (Promise.race([work, timeout])). Always attach a
catch or await inside try/catch — an unhandled rejection crashes Node and
logs a warning in browsers.