Merge pull request #1799 from leviding/patch-5

Fix error in 1-js/11-async/05-promise-api/article.md
This commit is contained in:
Ilya Kantor 2020-03-21 21:14:32 +03:00 committed by GitHub
commit 40847464c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -191,7 +191,7 @@ if(!Promise.allSettled) {
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. 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.
That handler turns a successful result `v` into `{state:'fulfilled', value:v}`, and an error `r` into `{state:'rejected', reason:r}`. That's exactly the format of `Promise.allSettled`. 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`.
Now we can use `Promise.allSettled` to get the results of *all* given promises, even if some of them reject. Now we can use `Promise.allSettled` to get the results of *all* given promises, even if some of them reject.