From 3a5d3de9344f7460f389419ab23ed99a491ffcb8 Mon Sep 17 00:00:00 2001 From: Bogdan Bacosca Date: Wed, 14 Dec 2022 11:41:24 +0200 Subject: [PATCH 1/6] line 56 replaced ids with IDs: not a big problem but potentially a helpful improvement --- 1-js/11-async/05-promise-api/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/11-async/05-promise-api/article.md b/1-js/11-async/05-promise-api/article.md index 7be84ce2cc..820d8ccdf2 100644 --- a/1-js/11-async/05-promise-api/article.md +++ b/1-js/11-async/05-promise-api/article.md @@ -53,7 +53,7 @@ Promise.all(requests) )); ``` -A bigger example with fetching user information for an array of GitHub users by their names (we could fetch an array of goods by their ids, the logic is identical): +A bigger example with fetching user information for an array of GitHub users by their names (we could fetch an array of goods by their IDs, the logic is identical): ```js run let names = ['iliakan', 'remy', 'jeresig']; From 82412891899c2dd83be09d93fa9a11d4a6582386 Mon Sep 17 00:00:00 2001 From: Bogdan Bacosca Date: Thu, 15 Dec 2022 04:18:14 +0200 Subject: [PATCH 2/6] line 67 fixed abbreviation --- 1-js/11-async/05-promise-api/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/11-async/05-promise-api/article.md b/1-js/11-async/05-promise-api/article.md index 820d8ccdf2..d8e538fb20 100644 --- a/1-js/11-async/05-promise-api/article.md +++ b/1-js/11-async/05-promise-api/article.md @@ -64,7 +64,7 @@ Promise.all(requests) .then(responses => { // all responses are resolved successfully for(let response of responses) { - alert(`${response.url}: ${response.status}`); // shows 200 for every url + alert(`${response.url}: ${response.status}`); // shows 200 for every URL } return responses; From f3f5b1270598a6e64db7ad985f912b5e5846301c Mon Sep 17 00:00:00 2001 From: Bogdan Bacosca Date: Thu, 15 Dec 2022 04:24:40 +0200 Subject: [PATCH 3/6] line 74 suggested different wording --- 1-js/11-async/05-promise-api/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/11-async/05-promise-api/article.md b/1-js/11-async/05-promise-api/article.md index d8e538fb20..5aac42de76 100644 --- a/1-js/11-async/05-promise-api/article.md +++ b/1-js/11-async/05-promise-api/article.md @@ -71,7 +71,7 @@ Promise.all(requests) }) // map array of responses into an array of response.json() to read their content .then(responses => Promise.all(responses.map(r => r.json()))) - // all JSON answers are parsed: "users" is the array of them + // all JSON answers are parsed into the "users" array .then(users => users.forEach(user => alert(user.name))); ``` From 045597247598b0eee1941b6635d6832f5387adc7 Mon Sep 17 00:00:00 2001 From: Bogdan Bacosca Date: Thu, 15 Dec 2022 04:36:53 +0200 Subject: [PATCH 4/6] line 72 fixed grammar --- 1-js/11-async/05-promise-api/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/11-async/05-promise-api/article.md b/1-js/11-async/05-promise-api/article.md index 5aac42de76..a59f350e3d 100644 --- a/1-js/11-async/05-promise-api/article.md +++ b/1-js/11-async/05-promise-api/article.md @@ -69,7 +69,7 @@ Promise.all(requests) return responses; }) - // map array of responses into an array of response.json() to read their content + // map the array of responses into an array of response.json() to read their content .then(responses => Promise.all(responses.map(r => r.json()))) // all JSON answers are parsed into the "users" array .then(users => users.forEach(user => alert(user.name))); From 4603935024ca24b866d9b45ad3d46975f82dab2f Mon Sep 17 00:00:00 2001 From: Bogdan Bacosca Date: Thu, 15 Dec 2022 04:44:27 +0200 Subject: [PATCH 5/6] line 94 fixed grammar --- 1-js/11-async/05-promise-api/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/11-async/05-promise-api/article.md b/1-js/11-async/05-promise-api/article.md index a59f350e3d..0c2eb7e32e 100644 --- a/1-js/11-async/05-promise-api/article.md +++ b/1-js/11-async/05-promise-api/article.md @@ -91,7 +91,7 @@ Promise.all([ Here the second promise rejects in two seconds. That leads to an immediate rejection of `Promise.all`, so `.catch` executes: the rejection error becomes the outcome of the entire `Promise.all`. -```warn header="In case of an error, other promises are ignored" +```warn header="In case of an error, the other promises are ignored" If one promise rejects, `Promise.all` immediately rejects, completely forgetting about the other ones in the list. Their results are ignored. For example, if there are multiple `fetch` calls, like in the example above, and one fails, the others will still continue to execute, but `Promise.all` won't watch them anymore. They will probably settle, but their results will be ignored. From f477a579676e830506f065bf1e7d6398a175b945 Mon Sep 17 00:00:00 2001 From: Bogdan Bacosca Date: Sat, 17 Dec 2022 08:41:01 +0200 Subject: [PATCH 6/6] small suggestion replacing outcome with return value --- 1-js/11-async/05-promise-api/article.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/11-async/05-promise-api/article.md b/1-js/11-async/05-promise-api/article.md index 0c2eb7e32e..abad0f3d5e 100644 --- a/1-js/11-async/05-promise-api/article.md +++ b/1-js/11-async/05-promise-api/article.md @@ -89,7 +89,7 @@ Promise.all([ ]).catch(alert); // Error: Whoops! ``` -Here the second promise rejects in two seconds. That leads to an immediate rejection of `Promise.all`, so `.catch` executes: the rejection error becomes the outcome of the entire `Promise.all`. +Here the second promise rejects in two seconds. That leads to an immediate rejection of `Promise.all`, so `.catch` executes: the rejection error becomes the return value of the entire `Promise.all`. ```warn header="In case of an error, the other promises are ignored" If one promise rejects, `Promise.all` immediately rejects, completely forgetting about the other ones in the list. Their results are ignored. @@ -315,8 +315,8 @@ There are 6 static methods of `Promise` class: 2. `Promise.allSettled(promises)` (recently added method) -- waits for all promises to settle and returns their results as an array of objects with: - `status`: `"fulfilled"` or `"rejected"` - `value` (if fulfilled) or `reason` (if rejected). -3. `Promise.race(promises)` -- waits for the first promise to settle, and its result/error becomes the outcome. -4. `Promise.any(promises)` (recently added method) -- waits for the first promise to fulfill, and its result becomes the outcome. If all of the given promises are rejected, [`AggregateError`](mdn:js/AggregateError) becomes the error of `Promise.any`. +3. `Promise.race(promises)` -- waits for the first promise to settle, and its result/error becomes the return value. +4. `Promise.any(promises)` (recently added method) -- waits for the first promise to fulfill, and its result becomes the return value. If all of the given promises are rejected, [`AggregateError`](mdn:js/AggregateError) becomes the error of `Promise.any`. 5. `Promise.resolve(value)` -- makes a resolved promise with the given value. 6. `Promise.reject(error)` -- makes a rejected promise with the given error.