You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this code, `promises.map` takes input values, turns them into promises (just in case a non-promise was passed) with `p => Promise.resolve(p)`, and then adds `.then` handler to every one.
193
193
194
-
That handler turns a successful result `value` into `{state:'fulfilled', value}`, and an error `reason` into `{state:'rejected', reason}`. That's exactly the format of `Promise.allSettled`.
194
+
That handler turns a successful result `value` into `{status:'fulfilled', value}`, and an error `reason` into `{status:'rejected', reason}`. That's exactly the format of `Promise.allSettled`.
195
195
196
196
Now we can use `Promise.allSettled` to get the results of *all* given promises, even if some of them reject.
197
197
@@ -277,7 +277,7 @@ There are 5 static methods of `Promise` class:
277
277
278
278
1. `Promise.all(promises)` -- waits for all promises to resolve and returns an array of their results. If any of the given promises rejects, it becomes the error of `Promise.all`, and all other results are ignored.
279
279
2. `Promise.allSettled(promises)` (recently added method) -- waits for all promises to settle and returns their results as an array of objects with:
280
-
- `state`: `"fulfilled"` or `"rejected"`
280
+
- `status`: `"fulfilled"` or `"rejected"`
281
281
- `value` (if fulfilled) or `reason` (if rejected).
282
282
3. `Promise.race(promises)` -- waits for the first promise to settle, and its result/error becomes the outcome.
283
283
4. `Promise.resolve(value)` -- makes a resolved promise with the given value.
0 commit comments