aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMDN <actions@users.noreply.github.com>2022-03-08 00:12:08 +0000
committerMDN <actions@users.noreply.github.com>2022-03-08 00:12:08 +0000
commitd53bae971e455859229bcb3246e29bcbc85179d2 (patch)
tree396c8a403d46802b365aa8d26183f6b18f2a1c6e
parent0c6e68897d9b4182437d58e376dbb48ee6947f71 (diff)
downloadtranslated-content-d53bae971e455859229bcb3246e29bcbc85179d2.tar.gz
translated-content-d53bae971e455859229bcb3246e29bcbc85179d2.tar.bz2
translated-content-d53bae971e455859229bcb3246e29bcbc85179d2.zip
[CRON] sync translated content
-rw-r--r--files/es/_redirects.txt1
-rw-r--r--files/es/_wikihistory.json2
-rw-r--r--files/es/learn/javascript/asynchronous/introducing/index.html (renamed from files/es/learn/javascript/asynchronous/concepts/index.html)3
-rw-r--r--files/fr/_redirects.txt5
-rw-r--r--files/fr/conflicting/learn/javascript/asynchronous/index.md (renamed from files/fr/learn/javascript/asynchronous/choosing_the_right_approach/index.md)3
-rw-r--r--files/fr/conflicting/learn/javascript/asynchronous/introducing/index.md (renamed from files/fr/learn/javascript/asynchronous/concepts/index.md)3
-rw-r--r--files/fr/conflicting/learn/javascript/asynchronous/promises/index.md (renamed from files/fr/learn/javascript/asynchronous/async_await/index.md)3
-rw-r--r--files/fr/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.md (renamed from files/fr/learn/javascript/asynchronous/timeouts_and_intervals/index.md)3
-rw-r--r--files/fr/conflicting/web/api/performance/resourcetimingbufferfull_event/index.md (renamed from files/fr/web/api/performance/onresourcetimingbufferfull/index.md)3
-rw-r--r--files/ja/_redirects.txt5
-rw-r--r--files/ja/_wikihistory.json28
-rw-r--r--files/ja/conflicting/web/api/performance/resourcetimingbufferfull_event/index.md (renamed from files/ja/web/api/performance/onresourcetimingbufferfull/index.md)5
-rw-r--r--files/ja/conflicting/web/api/window/appinstalled_event/index.html (renamed from files/ja/web/api/window/onappinstalled/index.html)4
-rw-r--r--files/ja/learn/javascript/asynchronous/introducing/index.html (renamed from files/ja/learn/javascript/asynchronous/concepts/index.html)3
-rw-r--r--files/ko/_redirects.txt3
-rw-r--r--files/ko/_wikihistory.json44
-rw-r--r--files/ko/conflicting/learn/javascript/asynchronous/index.html (renamed from files/ko/learn/javascript/asynchronous/timeouts_and_intervals/index.html)3
-rw-r--r--files/ko/conflicting/learn/javascript/asynchronous/introducing/index.html (renamed from files/ko/learn/javascript/asynchronous/concepts/index.html)3
-rw-r--r--files/ko/conflicting/learn/javascript/asynchronous/promises/index.html (renamed from files/ko/learn/javascript/asynchronous/async_await/index.html)9
-rw-r--r--files/pt-br/_redirects.txt8
-rw-r--r--files/pt-br/_wikihistory.json40
-rw-r--r--files/pt-br/conflicting/learn/javascript/asynchronous/index.html (renamed from files/pt-br/learn/javascript/asynchronous/choosing_the_right_approach/index.html)4
-rw-r--r--files/pt-br/conflicting/learn/javascript/asynchronous/introducing/index.html (renamed from files/pt-br/learn/javascript/asynchronous/concepts/index.html)4
-rw-r--r--files/pt-br/conflicting/learn/javascript/asynchronous/promises/index.html (renamed from files/pt-br/learn/javascript/asynchronous/async_await/index.html)250
-rw-r--r--files/pt-br/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.html (renamed from files/pt-br/learn/javascript/asynchronous/timeouts_and_intervals/index.html)3
-rw-r--r--files/ru/_redirects.txt5
-rw-r--r--files/ru/_wikihistory.json36
-rw-r--r--files/ru/conflicting/learn/javascript/asynchronous/index.html (renamed from files/ru/learn/javascript/asynchronous/timeouts_and_intervals/index.html)4
-rw-r--r--files/ru/conflicting/learn/javascript/asynchronous/introducing/index.html (renamed from files/ru/learn/javascript/asynchronous/concepts/index.html)3
-rw-r--r--files/ru/learn/javascript/asynchronous/promises/index.html (renamed from files/ru/learn/javascript/asynchronous/async_await/index.html)3
-rw-r--r--files/zh-cn/_redirects.txt15
-rw-r--r--files/zh-cn/_wikihistory.json128
-rw-r--r--files/zh-cn/conflicting/learn/javascript/asynchronous/index.html (renamed from files/zh-cn/learn/javascript/asynchronous/choosing_the_right_approach/index.html)4
-rw-r--r--files/zh-cn/conflicting/learn/javascript/asynchronous/introducing/index.html (renamed from files/zh-cn/learn/javascript/asynchronous/concepts/index.html)4
-rw-r--r--files/zh-cn/conflicting/learn/javascript/asynchronous/promises/index.html (renamed from files/zh-cn/learn/javascript/asynchronous/async_await/index.html)4
-rw-r--r--files/zh-cn/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.html (renamed from files/zh-cn/learn/javascript/asynchronous/timeouts_and_intervals/index.html)4
-rw-r--r--files/zh-cn/conflicting/web/api/document/visibilitychange_event/index.html (renamed from files/zh-cn/web/api/document/onvisibilitychange/index.html)3
-rw-r--r--files/zh-cn/web/api/performance/resourcetimingbufferfull_event/index.html (renamed from files/zh-cn/web/api/performance/onresourcetimingbufferfull/index.html)3
-rw-r--r--files/zh-cn/web/api/window/appinstalled_event/index.html (renamed from files/zh-cn/web/api/window/onappinstalled/index.html)3
-rw-r--r--files/zh-tw/_redirects.txt4
-rw-r--r--files/zh-tw/conflicting/learn/javascript/asynchronous/index.html (renamed from files/zh-tw/learn/javascript/asynchronous/choosing_the_right_approach/index.html)3
-rw-r--r--files/zh-tw/conflicting/learn/javascript/asynchronous/introducing/index.html (renamed from files/zh-tw/learn/javascript/asynchronous/concepts/index.html)3
-rw-r--r--files/zh-tw/conflicting/learn/javascript/asynchronous/promises/index.html (renamed from files/zh-tw/learn/javascript/asynchronous/async_await/index.html)3
-rw-r--r--files/zh-tw/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.html (renamed from files/zh-tw/learn/javascript/asynchronous/timeouts_and_intervals/index.html)5
44 files changed, 365 insertions, 314 deletions
diff --git a/files/es/_redirects.txt b/files/es/_redirects.txt
index 0216d3ebb5..f62d9cc572 100644
--- a/files/es/_redirects.txt
+++ b/files/es/_redirects.txt
@@ -1179,6 +1179,7 @@
/es/docs/Learn/Herramientas_y_pruebas/Lado-del-cliente_JavaScript_frameworks /es/docs/Learn/Tools_and_testing/Client-side_JavaScript_frameworks
/es/docs/Learn/Herramientas_y_pruebas/Lado-del-cliente_JavaScript_frameworks/React_getting_started /es/docs/Learn/Tools_and_testing/Client-side_JavaScript_frameworks/React_getting_started
/es/docs/Learn/Herramientas_y_pruebas/Understanding_client-side_tools /es/docs/Learn/Tools_and_testing/Understanding_client-side_tools
+/es/docs/Learn/JavaScript/Asynchronous/Concepts /es/docs/Learn/JavaScript/Asynchronous/Introducing
/es/docs/Learn/JavaScript/Building_blocks/Bucle_codigo /es/docs/Learn/JavaScript/Building_blocks/Looping_code
/es/docs/Learn/JavaScript/Building_blocks/Construyendo_tu_propia_funcion /es/docs/Learn/JavaScript/Building_blocks/Build_your_own_function
/es/docs/Learn/JavaScript/Client-side_web_APIs/Introducción /es/docs/Learn/JavaScript/Client-side_web_APIs/Introduction
diff --git a/files/es/_wikihistory.json b/files/es/_wikihistory.json
index 6466283b7a..6156c5aff5 100644
--- a/files/es/_wikihistory.json
+++ b/files/es/_wikihistory.json
@@ -2943,7 +2943,7 @@
"madmaxdios"
]
},
- "Learn/JavaScript/Asynchronous/Concepts": {
+ "Learn/JavaScript/Asynchronous/Introducing": {
"modified": "2020-11-19T20:30:13.091Z",
"contributors": [
"AndresSalomon1990",
diff --git a/files/es/learn/javascript/asynchronous/concepts/index.html b/files/es/learn/javascript/asynchronous/introducing/index.html
index d5babeb8ba..85f605b479 100644
--- a/files/es/learn/javascript/asynchronous/concepts/index.html
+++ b/files/es/learn/javascript/asynchronous/introducing/index.html
@@ -1,6 +1,6 @@
---
title: General asynchronous programming concepts
-slug: Learn/JavaScript/Asynchronous/Concepts
+slug: Learn/JavaScript/Asynchronous/Introducing
tags:
- Aprender
- Hilos
@@ -9,6 +9,7 @@ tags:
- Threads
- bloques
translation_of: Learn/JavaScript/Asynchronous/Concepts
+original_slug: Learn/JavaScript/Asynchronous/Concepts
---
<div>{{LearnSidebar}}{{NextMenu("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous")}}</div>
diff --git a/files/fr/_redirects.txt b/files/fr/_redirects.txt
index 3bc4db62c8..2f4624d9d5 100644
--- a/files/fr/_redirects.txt
+++ b/files/fr/_redirects.txt
@@ -2997,6 +2997,10 @@
/fr/docs/Learn/CSS/First_steps/Qu_est_ce_que_CSS /fr/docs/Learn/CSS/First_steps/What_is_CSS
/fr/docs/Learn/CSS/Styling_text/Mise_en_forme_des_liens /fr/docs/Learn/CSS/Styling_text/Styling_links
/fr/docs/Learn/CSS/Styling_text/initiation-mise-en-forme-du-texte /fr/docs/Learn/CSS/Styling_text/Fundamentals
+/fr/docs/Learn/JavaScript/Asynchronous/Async_await /fr/docs/conflicting/Learn/JavaScript/Asynchronous/Promises
+/fr/docs/Learn/JavaScript/Asynchronous/Choosing_the_right_approach /fr/docs/conflicting/Learn/JavaScript/Asynchronous
+/fr/docs/Learn/JavaScript/Asynchronous/Concepts /fr/docs/conflicting/Learn/JavaScript/Asynchronous/Introducing
+/fr/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals /fr/docs/conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df
/fr/docs/Learn/JavaScript/First_steps/Testes_vos_competence:_Tableaux /fr/docs/Learn/JavaScript/First_steps/Test_your_skills:_Arrays
/fr/docs/Learn/JavaScript/First_steps/methode_chaine_utile /fr/docs/Learn/JavaScript/First_steps/Useful_string_methods
/fr/docs/Learn/JavaScript/First_steps/tableaux /fr/docs/Learn/JavaScript/First_steps/Arrays
@@ -3713,6 +3717,7 @@
/fr/docs/Web/API/PasswordCredential/idName /fr/docs/conflicting/Web/API/PasswordCredential_cbf7b306e83a3f58ff06bccf89637c12
/fr/docs/Web/API/PasswordCredential/passwordName /fr/docs/conflicting/Web/API/PasswordCredential_bc57d5dfa87242b4fb83497887124f41
/fr/docs/Web/API/Performance.now() /fr/docs/Web/API/Performance/now
+/fr/docs/Web/API/Performance/onresourcetimingbufferfull /fr/docs/conflicting/Web/API/Performance/resourcetimingbufferfull_event
/fr/docs/Web/API/Pointer_events/gestes_pincer_zoom /fr/docs/Web/API/Pointer_events/Pinch_zoom_gestures
/fr/docs/Web/API/PositionOptions /fr/docs/conflicting/Web/API/Geolocation/getCurrentPosition_5852407122355d2ab39863042583c266
/fr/docs/Web/API/PositionOptions/enableHighAccuracy /fr/docs/conflicting/Web/API/Geolocation/getCurrentPosition
diff --git a/files/fr/learn/javascript/asynchronous/choosing_the_right_approach/index.md b/files/fr/conflicting/learn/javascript/asynchronous/index.md
index 679212748d..b2b9afbcd1 100644
--- a/files/fr/learn/javascript/asynchronous/choosing_the_right_approach/index.md
+++ b/files/fr/conflicting/learn/javascript/asynchronous/index.md
@@ -1,6 +1,6 @@
---
title: Choisir la bonne approche
-slug: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
+slug: conflicting/Learn/JavaScript/Asynchronous
tags:
- Beginner
- Intervals
@@ -16,6 +16,7 @@ tags:
- setTimeout
- timeouts
translation_of: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
+original_slug: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
---
{{LearnSidebar}}{{PreviousMenu("Learn/JavaScript/Asynchronous/Async_await", "Learn/JavaScript/Asynchronous")}}
diff --git a/files/fr/learn/javascript/asynchronous/concepts/index.md b/files/fr/conflicting/learn/javascript/asynchronous/introducing/index.md
index 03dc27feaf..2fadd1a162 100644
--- a/files/fr/learn/javascript/asynchronous/concepts/index.md
+++ b/files/fr/conflicting/learn/javascript/asynchronous/introducing/index.md
@@ -1,6 +1,6 @@
---
title: Concepts généraux de programmation asynchrone
-slug: Learn/JavaScript/Asynchronous/Concepts
+slug: conflicting/Learn/JavaScript/Asynchronous/Introducing
tags:
- JavaScript
- Learn
@@ -9,6 +9,7 @@ tags:
- asynchronous
- blocking
translation_of: Learn/JavaScript/Asynchronous/Concepts
+original_slug: Learn/JavaScript/Asynchronous/Concepts
---
{{LearnSidebar}}{{NextMenu("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous")}}
diff --git a/files/fr/learn/javascript/asynchronous/async_await/index.md b/files/fr/conflicting/learn/javascript/asynchronous/promises/index.md
index a7578c08e1..93a26dd1b8 100644
--- a/files/fr/learn/javascript/asynchronous/async_await/index.md
+++ b/files/fr/conflicting/learn/javascript/asynchronous/promises/index.md
@@ -1,6 +1,6 @@
---
title: Faciliter la programmation asynchrone avec async et await
-slug: Learn/JavaScript/Asynchronous/Async_await
+slug: conflicting/Learn/JavaScript/Asynchronous/Promises
tags:
- Beginner
- CodingScripting
@@ -12,6 +12,7 @@ tags:
- asynchronous
- await
translation_of: Learn/JavaScript/Asynchronous/Async_await
+original_slug: Learn/JavaScript/Asynchronous/Async_await
---
{{LearnSidebar}}{{PreviousMenuNext("Learn/JavaScript/Asynchronous/Promises", "Learn/JavaScript/Asynchronous/Choosing_the_right_approach", "Learn/JavaScript/Asynchronous")}}
diff --git a/files/fr/learn/javascript/asynchronous/timeouts_and_intervals/index.md b/files/fr/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.md
index 890896be61..11ea92030f 100644
--- a/files/fr/learn/javascript/asynchronous/timeouts_and_intervals/index.md
+++ b/files/fr/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.md
@@ -1,6 +1,6 @@
---
title: 'JavaScript asynchrone coopératif : délais et intervalles'
-slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+slug: conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df
tags:
- Animation
- Beginner
@@ -15,6 +15,7 @@ tags:
- setTimeout
- timeouts
translation_of: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+original_slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
---
{{LearnSidebar}}{{PreviousMenuNext("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous/Promises", "Learn/JavaScript/Asynchronous")}}
diff --git a/files/fr/web/api/performance/onresourcetimingbufferfull/index.md b/files/fr/conflicting/web/api/performance/resourcetimingbufferfull_event/index.md
index d904faab49..d1073d834b 100644
--- a/files/fr/web/api/performance/onresourcetimingbufferfull/index.md
+++ b/files/fr/conflicting/web/api/performance/resourcetimingbufferfull_event/index.md
@@ -1,6 +1,6 @@
---
title: performance.onresourcetimingbufferfull
-slug: Web/API/Performance/onresourcetimingbufferfull
+slug: conflicting/Web/API/Performance/resourcetimingbufferfull_event
tags:
- API
- Method
@@ -8,6 +8,7 @@ tags:
- Reference
- Performance web
translation_of: Web/API/Performance/onresourcetimingbufferfull
+original_slug: Web/API/Performance/onresourcetimingbufferfull
---
{{APIRef("Resource Timing API")}}
diff --git a/files/ja/_redirects.txt b/files/ja/_redirects.txt
index 82f79f7a60..3adaee9525 100644
--- a/files/ja/_redirects.txt
+++ b/files/ja/_redirects.txt
@@ -2693,6 +2693,7 @@
/ja/docs/Learn/HTML/Forms/Your_first_HTML_form /ja/docs/Learn/Forms/Your_first_form
/ja/docs/Learn/HTML/Forms/Your_first_HTML_form/Example /ja/docs/Learn/Forms/Your_first_form/Example
/ja/docs/Learn/HTML/Introduction_to_HTML/高度なテキスト成型 /ja/docs/Learn/HTML/Introduction_to_HTML/Advanced_text_formatting
+/ja/docs/Learn/JavaScript/Asynchronous/Concepts /ja/docs/Learn/JavaScript/Asynchronous/Introducing
/ja/docs/Learn/JavaScript/Objects/Inheritance /ja/docs/Learn/JavaScript/Objects/Classes_in_JavaScript
/ja/docs/Learn/JavaScript/Objects/Object-oriented_JS /ja/docs/conflicting/Learn/JavaScript/Objects/Classes_in_JavaScript
/ja/docs/Learn/JavaScript/Objects/継承 /ja/docs/Learn/JavaScript/Objects/Classes_in_JavaScript
@@ -3239,6 +3240,7 @@
/ja/docs/Web/API/Node/prefix /ja/docs/Web/API/Element/prefix
/ja/docs/Web/API/NodeList.item /ja/docs/Web/API/NodeList/item
/ja/docs/Web/API/NonDocumentTypeChildNode /ja/docs/Web/API/Element
+/ja/docs/Web/API/Performance/onresourcetimingbufferfull /ja/docs/conflicting/Web/API/Performance/resourcetimingbufferfull_event
/ja/docs/Web/API/Position /ja/docs/Web/API/GeolocationPosition
/ja/docs/Web/API/PositionError /ja/docs/Web/API/GeolocationPositionError
/ja/docs/Web/API/PositionOptions /ja/docs/conflicting/Web/API/Geolocation/getCurrentPosition
@@ -3338,6 +3340,7 @@
/ja/docs/Web/API/Window/escape /ja/docs/Web/JavaScript/Reference/Global_Objects/escape
/ja/docs/Web/API/Window/getAttention /ja/docs/orphaned/Web/API/Window/getAttention
/ja/docs/Web/API/Window/onafterprint /ja/docs/Web/API/WindowEventHandlers/onafterprint
+/ja/docs/Web/API/Window/onappinstalled /ja/docs/conflicting/Web/API/Window/appinstalled_event
/ja/docs/Web/API/Window/onblur /ja/docs/Web/API/GlobalEventHandlers/onblur
/ja/docs/Web/API/Window/onchange /ja/docs/Web/API/GlobalEventHandlers/onchange
/ja/docs/Web/API/Window/onclick /ja/docs/Web/API/GlobalEventHandlers/onclick
@@ -3345,7 +3348,7 @@
/ja/docs/Web/API/Window/onfocus /ja/docs/Web/API/GlobalEventHandlers/onfocus
/ja/docs/Web/API/Window/ongamepadconnected /ja/docs/conflicting/Web/API/Window/gamepadconnected_event
/ja/docs/Web/API/Window/ongamepaddisconnected /ja/docs/conflicting/Web/API/Window/gamepaddisconnected_event
-/ja/docs/Web/API/Window/oninstall /ja/docs/Web/API/Window/onappinstalled
+/ja/docs/Web/API/Window/oninstall /ja/docs/conflicting/Web/API/Window/appinstalled_event
/ja/docs/Web/API/Window/onkeydown /ja/docs/Web/API/GlobalEventHandlers/onkeydown
/ja/docs/Web/API/Window/onkeyup /ja/docs/Web/API/GlobalEventHandlers/onkeyup
/ja/docs/Web/API/Window/onmousedown /ja/docs/Web/API/GlobalEventHandlers/onmousedown
diff --git a/files/ja/_wikihistory.json b/files/ja/_wikihistory.json
index acf6f16c9e..d17ceed58b 100644
--- a/files/ja/_wikihistory.json
+++ b/files/ja/_wikihistory.json
@@ -5165,7 +5165,7 @@
"y-kazunori"
]
},
- "Learn/JavaScript/Asynchronous/Concepts": {
+ "Learn/JavaScript/Asynchronous/Introducing": {
"modified": "2020-12-04T08:53:53.277Z",
"contributors": [
"Uemmra3",
@@ -19794,12 +19794,6 @@
"takamin"
]
},
- "Web/API/Performance/onresourcetimingbufferfull": {
- "modified": "2020-10-15T22:19:53.003Z",
- "contributors": [
- "silverskyvicto"
- ]
- },
"Web/API/Performance/resourcetimingbufferfull_event": {
"modified": "2020-10-15T22:19:38.048Z",
"contributors": [
@@ -24428,13 +24422,6 @@
"Potappo"
]
},
- "Web/API/Window/onappinstalled": {
- "modified": "2020-10-15T21:49:27.262Z",
- "contributors": [
- "Marsf",
- "YuichiNukiyama"
- ]
- },
"Web/API/Window/ondevicemotion": {
"modified": "2020-10-15T22:28:07.002Z",
"contributors": [
@@ -48425,6 +48412,12 @@
"Koyamak"
]
},
+ "conflicting/Web/API/Performance/resourcetimingbufferfull_event": {
+ "modified": "2020-10-15T22:19:53.003Z",
+ "contributors": [
+ "silverskyvicto"
+ ]
+ },
"conflicting/Web/API/Pointer_events": {
"modified": "2019-03-18T20:45:32.564Z",
"contributors": [
@@ -48504,6 +48497,13 @@
"mfuji09"
]
},
+ "conflicting/Web/API/Window/appinstalled_event": {
+ "modified": "2020-10-15T21:49:27.262Z",
+ "contributors": [
+ "Marsf",
+ "YuichiNukiyama"
+ ]
+ },
"conflicting/Web/API/Window/gamepadconnected_event": {
"modified": "2020-10-15T22:12:53.034Z",
"contributors": [
diff --git a/files/ja/web/api/performance/onresourcetimingbufferfull/index.md b/files/ja/conflicting/web/api/performance/resourcetimingbufferfull_event/index.md
index 7c13934198..d025f57362 100644
--- a/files/ja/web/api/performance/onresourcetimingbufferfull/index.md
+++ b/files/ja/conflicting/web/api/performance/resourcetimingbufferfull_event/index.md
@@ -1,13 +1,14 @@
---
title: Performance.onresourcetimingbufferfull
-slug: Web/API/Performance/onresourcetimingbufferfull
+slug: conflicting/Web/API/Performance/resourcetimingbufferfull_event
tags:
- API
- プロパティ
- リファレンス
- ウェブパフォーマンス
-browser-compat: api.Performance.onresourcetimingbufferfull
translation_of: Web/API/Performance/onresourcetimingbufferfull
+original_slug: Web/API/Performance/onresourcetimingbufferfull
+browser-compat: api.Performance.onresourcetimingbufferfull
---
{{APIRef("Resource Timing API")}}
diff --git a/files/ja/web/api/window/onappinstalled/index.html b/files/ja/conflicting/web/api/window/appinstalled_event/index.html
index f59a7a86fb..4f31793823 100644
--- a/files/ja/web/api/window/onappinstalled/index.html
+++ b/files/ja/conflicting/web/api/window/appinstalled_event/index.html
@@ -1,6 +1,6 @@
---
title: Window.onappinstalled
-slug: Web/API/Window/onappinstalled
+slug: conflicting/Web/API/Window/appinstalled_event
tags:
- API
- Event Handler
@@ -9,7 +9,7 @@ tags:
- Window
- web manifest
translation_of: Web/API/Window/onappinstalled
-original_slug: Web/API/Window/oninstall
+original_slug: Web/API/Window/onappinstalled
---
<div>{{APIRef}}</div>
diff --git a/files/ja/learn/javascript/asynchronous/concepts/index.html b/files/ja/learn/javascript/asynchronous/introducing/index.html
index b2baeaac4e..439c09bd13 100644
--- a/files/ja/learn/javascript/asynchronous/concepts/index.html
+++ b/files/ja/learn/javascript/asynchronous/introducing/index.html
@@ -1,6 +1,6 @@
---
title: 非同期プログラミングの一般的概念
-slug: Learn/JavaScript/Asynchronous/Concepts
+slug: Learn/JavaScript/Asynchronous/Introducing
tags:
- JavaScript
- Learn
@@ -9,6 +9,7 @@ tags:
- asynchronous
- blocking
translation_of: Learn/JavaScript/Asynchronous/Concepts
+original_slug: Learn/JavaScript/Asynchronous/Concepts
---
<div>{{LearnSidebar}}{{NextMenu("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous")}}</div>
diff --git a/files/ko/_redirects.txt b/files/ko/_redirects.txt
index dec0d5b016..f8ecb5e8f5 100644
--- a/files/ko/_redirects.txt
+++ b/files/ko/_redirects.txt
@@ -313,6 +313,9 @@
/ko/docs/Learn/HTML/Forms/Your_first_HTML_form /ko/docs/Learn/Forms/Your_first_form
/ko/docs/Learn/HTML/Howto/데이터_속성_사용하기 /ko/docs/Learn/HTML/Howto/Use_data_attributes
/ko/docs/Learn/HTML/Multimedia_and_embedding/ideo_and_audio_content /ko/docs/Learn/HTML/Multimedia_and_embedding/Video_and_audio_content
+/ko/docs/Learn/JavaScript/Asynchronous/Async_await /ko/docs/conflicting/Learn/JavaScript/Asynchronous/Promises
+/ko/docs/Learn/JavaScript/Asynchronous/Concepts /ko/docs/conflicting/Learn/JavaScript/Asynchronous/Introducing
+/ko/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals /ko/docs/conflicting/Learn/JavaScript/Asynchronous
/ko/docs/Learn/JavaScript/Building_blocks/조건문 /ko/docs/Learn/JavaScript/Building_blocks/conditionals
/ko/docs/Learn/JavaScript/Objects/Inheritance /ko/docs/Learn/JavaScript/Objects/Classes_in_JavaScript
/ko/docs/Learn/JavaScript/Objects/Object-oriented_JS /ko/docs/conflicting/Learn/JavaScript/Objects/Classes_in_JavaScript
diff --git a/files/ko/_wikihistory.json b/files/ko/_wikihistory.json
index b4a8b6a3ff..ecc1af296f 100644
--- a/files/ko/_wikihistory.json
+++ b/files/ko/_wikihistory.json
@@ -1888,22 +1888,6 @@
"Sheppy"
]
},
- "Learn/JavaScript/Asynchronous/Async_await": {
- "modified": "2020-11-28T09:53:12.946Z",
- "contributors": [
- "HerbertLim",
- "chupark"
- ]
- },
- "Learn/JavaScript/Asynchronous/Concepts": {
- "modified": "2020-11-17T21:41:39.368Z",
- "contributors": [
- "mochapoke",
- "Plut0",
- "chupark",
- "eunjungleecub"
- ]
- },
"Learn/JavaScript/Asynchronous/Introducing": {
"modified": "2020-11-17T21:53:14.519Z",
"contributors": [
@@ -1918,12 +1902,6 @@
"chupark"
]
},
- "Learn/JavaScript/Asynchronous/Timeouts_and_intervals": {
- "modified": "2020-07-16T22:33:21.049Z",
- "contributors": [
- "cjkcc69"
- ]
- },
"Learn/JavaScript/Building_blocks": {
"modified": "2020-07-16T22:31:09.649Z",
"contributors": [
@@ -17457,6 +17435,28 @@
"Kaben"
]
},
+ "conflicting/Learn/JavaScript/Asynchronous": {
+ "modified": "2020-07-16T22:33:21.049Z",
+ "contributors": [
+ "cjkcc69"
+ ]
+ },
+ "conflicting/Learn/JavaScript/Asynchronous/Introducing": {
+ "modified": "2020-11-17T21:41:39.368Z",
+ "contributors": [
+ "mochapoke",
+ "Plut0",
+ "chupark",
+ "eunjungleecub"
+ ]
+ },
+ "conflicting/Learn/JavaScript/Asynchronous/Promises": {
+ "modified": "2020-11-28T09:53:12.946Z",
+ "contributors": [
+ "HerbertLim",
+ "chupark"
+ ]
+ },
"conflicting/Learn/JavaScript/Objects": {
"modified": "2019-03-23T23:29:46.029Z",
"contributors": [
diff --git a/files/ko/learn/javascript/asynchronous/timeouts_and_intervals/index.html b/files/ko/conflicting/learn/javascript/asynchronous/index.html
index 378f0a5f55..19f9ffd02d 100644
--- a/files/ko/learn/javascript/asynchronous/timeouts_and_intervals/index.html
+++ b/files/ko/conflicting/learn/javascript/asynchronous/index.html
@@ -1,7 +1,8 @@
---
title: 'Cooperative asynchronous JavaScript: Timeouts and intervals'
-slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+slug: conflicting/Learn/JavaScript/Asynchronous
translation_of: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+original_slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
---
<div>{{LearnSidebar}}</div>
diff --git a/files/ko/learn/javascript/asynchronous/concepts/index.html b/files/ko/conflicting/learn/javascript/asynchronous/introducing/index.html
index 8b1a12bf46..7e3d68c37d 100644
--- a/files/ko/learn/javascript/asynchronous/concepts/index.html
+++ b/files/ko/conflicting/learn/javascript/asynchronous/introducing/index.html
@@ -1,11 +1,12 @@
---
title: 일반적인 비동기 프로그래밍 개념
-slug: Learn/JavaScript/Asynchronous/Concepts
+slug: conflicting/Learn/JavaScript/Asynchronous/Introducing
tags:
- 비동기
- 비동기 프로그래밍
- 자바스크립트
translation_of: Learn/JavaScript/Asynchronous/Concepts
+original_slug: Learn/JavaScript/Asynchronous/Concepts
---
<div>{{LearnSidebar}}{{NextMenu("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous")}}</div>
diff --git a/files/ko/learn/javascript/asynchronous/async_await/index.html b/files/ko/conflicting/learn/javascript/asynchronous/promises/index.html
index 92a9d81dc6..bbe8ee7812 100644
--- a/files/ko/learn/javascript/asynchronous/async_await/index.html
+++ b/files/ko/conflicting/learn/javascript/asynchronous/promises/index.html
@@ -1,6 +1,6 @@
---
title: async와 await를 사용하여 비동기 프로그래밍을 쉽게 만들기
-slug: Learn/JavaScript/Asynchronous/Async_await
+slug: conflicting/Learn/JavaScript/Asynchronous/Promises
tags:
- Beginner
- CodingScripting
@@ -11,6 +11,7 @@ tags:
- async
- asynchronous
- await
+original_slug: Learn/JavaScript/Asynchronous/Async_await
---
<div>{{LearnSidebar}}</div>
@@ -304,7 +305,7 @@ displayContent()
}
  return newArr;
}
-
+
async function getResult() {
  let result = await makeResult(items); // Blocked on this line
  useThatResult(result); // Will not be executed before makeResult() is done
@@ -390,8 +391,8 @@ let han = new Person('Han', 'Solo', 25, 'male', ['Smuggling']);</pre>
<h2 id="Browser_support">브라우저 지원</h2>
-<p>async/await 사용 여부를 결정할 때 고려해야 할 한가지 사항은 이전 브라우저에 대한 지원입니다.
- promises와 마찬가지로 대부분의 최신 브라우저에서 사용할 수 있습니다.
+<p>async/await 사용 여부를 결정할 때 고려해야 할 한가지 사항은 이전 브라우저에 대한 지원입니다.
+ promises와 마찬가지로 대부분의 최신 브라우저에서 사용할 수 있습니다.
주요 지원 문제는 Internet Explorer 그리고 Opera Mini에서 발생합니다.</p>
<p>async/await을 사용하는데 브라우저 지원이 걱정되는 경우 <a href="https://babeljs.io/">BabelJS</a> 라이브러리를 사용하는 것을 고려해 볼 수 있습니다. BabelJS는 최신 자바스크립트를 사용하여 애플리케이션을 작성하고 사용자 브라우저에 필요한 변경사항을 Babel이 파악할 수 있도록 지원합니다. async/await를 지원하지 않는 브라우저를 만나면 Babel은 이전 브라우저에서 작동하는 polyfill를 자동으로 제공합니다.</p>
diff --git a/files/pt-br/_redirects.txt b/files/pt-br/_redirects.txt
index b1d7aa2343..3363b351ae 100644
--- a/files/pt-br/_redirects.txt
+++ b/files/pt-br/_redirects.txt
@@ -391,9 +391,13 @@
/pt-BR/docs/Learn/Common_questions/Que_software_eu_preciso /pt-BR/docs/Learn/Common_questions/What_software_do_I_need
/pt-BR/docs/Learn/Common_questions/ferramentas_de_desenvolvimento_do_navegador /pt-BR/docs/Learn/Common_questions/What_are_browser_developer_tools
/pt-BR/docs/Learn/Common_questions/o_que_e_um_web_server /pt-BR/docs/Learn/Common_questions/What_is_a_web_server
-/pt-BR/docs/Learn/JavaScript/Asynchronous/Conceitos /pt-BR/docs/Learn/JavaScript/Asynchronous/Concepts
-/pt-BR/docs/Learn/JavaScript/Asynchronous/Escolhendo_abordagem_correta /pt-BR/docs/Learn/JavaScript/Asynchronous/Choosing_the_right_approach
+/pt-BR/docs/Learn/JavaScript/Asynchronous/Async_await /pt-BR/docs/conflicting/Learn/JavaScript/Asynchronous/Promises
+/pt-BR/docs/Learn/JavaScript/Asynchronous/Choosing_the_right_approach /pt-BR/docs/conflicting/Learn/JavaScript/Asynchronous
+/pt-BR/docs/Learn/JavaScript/Asynchronous/Conceitos /pt-BR/docs/conflicting/Learn/JavaScript/Asynchronous/Introducing
+/pt-BR/docs/Learn/JavaScript/Asynchronous/Concepts /pt-BR/docs/conflicting/Learn/JavaScript/Asynchronous/Introducing
+/pt-BR/docs/Learn/JavaScript/Asynchronous/Escolhendo_abordagem_correta /pt-BR/docs/conflicting/Learn/JavaScript/Asynchronous
/pt-BR/docs/Learn/JavaScript/Asynchronous/Introdução /pt-BR/docs/Learn/JavaScript/Asynchronous/Introducing
+/pt-BR/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals /pt-BR/docs/conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df
/pt-BR/docs/Learn/JavaScript/First_steps/Gerador_de_historias_bobas /pt-BR/docs/Learn/JavaScript/First_steps/Silly_story_generator
/pt-BR/docs/Learn/JavaScript/First_steps/Matematica /pt-BR/docs/Learn/JavaScript/First_steps/Math
/pt-BR/docs/Learn/JavaScript/First_steps/O_que_e_JavaScript /pt-BR/docs/Learn/JavaScript/First_steps/What_is_JavaScript
diff --git a/files/pt-br/_wikihistory.json b/files/pt-br/_wikihistory.json
index 5b2ed45493..c050bf05f2 100644
--- a/files/pt-br/_wikihistory.json
+++ b/files/pt-br/_wikihistory.json
@@ -2036,19 +2036,6 @@
"Sheppy"
]
},
- "Learn/JavaScript/Asynchronous/Choosing_the_right_approach": {
- "modified": "2020-10-15T22:33:23.228Z",
- "contributors": [
- "manoelbjr"
- ]
- },
- "Learn/JavaScript/Asynchronous/Concepts": {
- "modified": "2020-10-06T09:57:59.299Z",
- "contributors": [
- "joseluizmonteirojr",
- "bellammuniz"
- ]
- },
"Learn/JavaScript/Asynchronous/Introducing": {
"modified": "2020-07-16T22:33:17.985Z",
"contributors": [
@@ -2062,13 +2049,6 @@
"luan0ap"
]
},
- "Learn/JavaScript/Asynchronous/Timeouts_and_intervals": {
- "modified": "2020-07-16T22:33:21.635Z",
- "contributors": [
- "vbarcellos",
- "bellammuniz"
- ]
- },
"Learn/JavaScript/Building_blocks": {
"modified": "2020-07-16T22:31:10.224Z",
"contributors": [
@@ -16274,6 +16254,26 @@
"LeonardoPacheco"
]
},
+ "conflicting/Learn/JavaScript/Asynchronous": {
+ "modified": "2020-10-15T22:33:23.228Z",
+ "contributors": [
+ "manoelbjr"
+ ]
+ },
+ "conflicting/Learn/JavaScript/Asynchronous/Introducing": {
+ "modified": "2020-10-06T09:57:59.299Z",
+ "contributors": [
+ "joseluizmonteirojr",
+ "bellammuniz"
+ ]
+ },
+ "conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df": {
+ "modified": "2020-07-16T22:33:21.635Z",
+ "contributors": [
+ "vbarcellos",
+ "bellammuniz"
+ ]
+ },
"conflicting/Learn/JavaScript/Objects": {
"modified": "2020-06-07T23:51:22.220Z",
"contributors": [
diff --git a/files/pt-br/learn/javascript/asynchronous/choosing_the_right_approach/index.html b/files/pt-br/conflicting/learn/javascript/asynchronous/index.html
index e168a76aef..e1ffe62fbe 100644
--- a/files/pt-br/learn/javascript/asynchronous/choosing_the_right_approach/index.html
+++ b/files/pt-br/conflicting/learn/javascript/asynchronous/index.html
@@ -1,8 +1,8 @@
---
title: Escolhendo a abordagem correta
-slug: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
+slug: conflicting/Learn/JavaScript/Asynchronous
translation_of: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
-original_slug: Learn/JavaScript/Asynchronous/Escolhendo_abordagem_correta
+original_slug: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
---
<div>{{LearnSidebar}}</div>
diff --git a/files/pt-br/learn/javascript/asynchronous/concepts/index.html b/files/pt-br/conflicting/learn/javascript/asynchronous/introducing/index.html
index 39ce5d5086..1d472307c8 100644
--- a/files/pt-br/learn/javascript/asynchronous/concepts/index.html
+++ b/files/pt-br/conflicting/learn/javascript/asynchronous/introducing/index.html
@@ -1,8 +1,8 @@
---
title: Conceitos gerais da programação assíncrona
-slug: Learn/JavaScript/Asynchronous/Concepts
+slug: conflicting/Learn/JavaScript/Asynchronous/Introducing
translation_of: Learn/JavaScript/Asynchronous/Concepts
-original_slug: Learn/JavaScript/Asynchronous/Conceitos
+original_slug: Learn/JavaScript/Asynchronous/Concepts
---
<div>{{LearnSidebar}}{{NextMenu("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous")}}</div>
diff --git a/files/pt-br/learn/javascript/asynchronous/async_await/index.html b/files/pt-br/conflicting/learn/javascript/asynchronous/promises/index.html
index dd6a558cfe..04a2b90ba4 100644
--- a/files/pt-br/learn/javascript/asynchronous/async_await/index.html
+++ b/files/pt-br/conflicting/learn/javascript/asynchronous/promises/index.html
@@ -1,6 +1,6 @@
---
title: Tornando mais fácil a programação assíncrona com async e await
-slug: Learn/JavaScript/Asynchronous/Async_await
+slug: conflicting/Learn/JavaScript/Asynchronous/Promises
translation_of: Learn/JavaScript/Asynchronous/Async_await
original_slug: Learn/JavaScript/Asynchronous/Async_await
---
@@ -30,14 +30,14 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<h3 id="A_palavra_chave_async">A palavra-chave async</h3>
<div><p>Em primeiro lugar, temos a palavra-chave <code>async</code>, que você coloca antes de uma declaração de função para transformá-la em uma função assíncrona. Uma <a href="/pt-BR/docs/Web/JavaScript/Reference/Statements/async_function">função assíncrona</a> é uma função que espera a possibilidade de a palavra-chave await ser usada para invocar código assíncrono.</p>
-
+
<p>Experimente digitar as seguintes linhas no console JS do seu navegador.</p>
<div class="code-example"><pre class="brush: js notranslate"><span class="token keyword">function</span> <span class="token function">hello</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token string">"Hello"</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token function">hello</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></pre><button aria-hidden="false" type="button" class="copy-icon"><span class="visually-hidden">Copiar para área de transferência</span></button></div>
<p>A funcão retorna "Hello" — nada de especial, certo?</p>
-
+
<p>Mas o que acontece se transformar-mos isso em uma função assíncrona? Tente o seguinte:</p>
<div class="code-example"><pre class="brush: js notranslate"><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">hello</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token string">"Hello"</span> <span class="token punctuation">}</span><span class="token punctuation">;</span>
@@ -55,7 +55,7 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<div class="code-example"><pre class="brush: js notranslate"><span class="token keyword">let</span> <span class="token function-variable function">hello</span> <span class="token operator">=</span> <span class="token keyword">async</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token string">"Hello"</span> <span class="token punctuation">}</span><span class="token punctuation">;</span></pre><button aria-hidden="false" type="button" class="copy-icon"><span class="visually-hidden">Copiar para área de transferência</span></button></div>
<p>Tudo isso faz basicamente a mesma coisa.</p>
-
+
<p>Para consumir o valor retornado quando a promise é finalizada, desde que esteja retornando uma promise, podemos usar um bloco <code>.then()</code>:</p>
<div class="code-example"><pre class="brush: js notranslate"><span class="token function">hello</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">value</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>value<span class="token punctuation">)</span><span class="token punctuation">)</span></pre><button aria-hidden="false" type="button" class="copy-icon"><span class="visually-hidden">Copiar para área de transferência</span></button></div>
@@ -70,30 +70,30 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
</div>
<h3 id="A_palavra_chave_await">A palavra-chave await</h3>
-
+
<div>
<p>A vantagem de uma função assíncrona só se torna aparente quando você a combina com a palavra-chave <a href="/pt-BR/docs/Web/JavaScript/Reference/Operators/await">await</a>. <code>await</code> só funciona dentro de funções assíncronas no código JavaScript regular, no entanto, pode ser usado por conta própria com <a href="/pt-BR/docs/Web/JavaScript/Guide/Modules">JavaScript modules.</a></p>
<p><code>await</code> pode ser colocado na frente de qualquer função assíncrona baseada em promise para pausar seu código nessa linha até que a promise seja resolvida e, em seguida, retornar o valor resultante.</p>
-
+
<p>Você pode usar <code>await</code> quando chamar qualquer função que retorne uma Promise, incluindo funções de API web.</p>
-
+
<p>Aqui está um exemplo comum:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">hello</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> greeting <span class="token operator">=</span> <span class="token keyword">await</span> Promise<span class="token punctuation">.</span><span class="token function">resolve</span><span class="token punctuation">(</span><span class="token string">"Hello"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
-
+
<span class="token function">hello</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span>alert<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>Com certeza, o exemplo acima não é muito útil, porém serve para ilustrar a sintaxe. Vamos seguir em frente e ver um exemplo real.</p>
</div>
-
+
<h2 id="Reescrevendo_codigo_baseado_em_promises_com_asyncawait">Reescrevendo código baseado em promises com async/await</a></h2>
-
+
<div>
<p>Vejamos um exemplo simples de busca que vimos no artigo anterior:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token function">fetch</span><span class="token punctuation">(</span><span class="token string">'coffee.jpg'</span><span class="token punctuation">)</span>
<span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token parameter">response</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>response<span class="token punctuation">.</span>ok<span class="token punctuation">)</span> <span class="token punctuation">{</span>
@@ -110,81 +110,81 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token parameter">e</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'There has been a problem with your fetch operation: '</span> <span class="token operator">+</span> e<span class="token punctuation">.</span>message<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>Por enquanto, você precisa ter um entendimento razoável das promises e como elas funcionam, mas vamos converter isso para usar async/await e ver o quão simples as coisas se tornam:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">myFetch</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> response <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">fetch</span><span class="token punctuation">(</span><span class="token string">'coffee.jpg'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>response<span class="token punctuation">.</span>ok<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">Error</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">HTTP error! status: </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>response<span class="token punctuation">.</span>status<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
-
+
<span class="token keyword">let</span> myBlob <span class="token operator">=</span> <span class="token keyword">await</span> response<span class="token punctuation">.</span><span class="token function">blob</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">let</span> objectURL <span class="token operator">=</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token function">createObjectURL</span><span class="token punctuation">(</span>myBlob<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> image <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">(</span><span class="token string">'img'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
image<span class="token punctuation">.</span>src <span class="token operator">=</span> objectURL<span class="token punctuation">;</span>
document<span class="token punctuation">.</span>body<span class="token punctuation">.</span><span class="token function">appendChild</span><span class="token punctuation">(</span>image<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
-
+
<span class="token function">myFetch</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token parameter">e</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">'There has been a problem with your fetch operation: '</span> <span class="token operator">+</span> e<span class="token punctuation">.</span>message<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>Isto faz o código muito mais simples and fácil de entender — sem mais blocos <code>.then()</code> em todo lugar!</p>
-
+
<p>Visto que a palavra-chave <code>async</code> transforma a funcão em uma promise, você pode refatorar seu código para usar uma abordagem de promises e await, trazendo a segunda metade da funcão para um novo bloco e torná-la mais flexível:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">myFetch</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> response <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">fetch</span><span class="token punctuation">(</span><span class="token string">'coffee.jpg'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>response<span class="token punctuation">.</span>ok<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">Error</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">HTTP error! status: </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>response<span class="token punctuation">.</span>status<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">return</span> <span class="token keyword">await</span> response<span class="token punctuation">.</span><span class="token function">blob</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token punctuation">}</span>
-
+
<span class="token function">myFetch</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">blob</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> objectURL <span class="token operator">=</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token function">createObjectURL</span><span class="token punctuation">(</span>blob<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> image <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">(</span><span class="token string">'img'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
image<span class="token punctuation">.</span>src <span class="token operator">=</span> objectURL<span class="token punctuation">;</span>
document<span class="token punctuation">.</span>body<span class="token punctuation">.</span><span class="token function">appendChild</span><span class="token punctuation">(</span>image<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token parameter">e</span> <span class="token operator">=&gt;</span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>Você pode tentar fazer o exemplo sozinho, ou rodar o nosso <a href="https://mdn.github.io/learning-area/javascript/asynchronous/async-await/simple-fetch-async-await.html" class="external" rel=" noopener">exemplo ao vivo</a> (veja também o<a href="https://github.com/mdn/learning-area/blob/master/javascript/asynchronous/async-await/simple-fetch-async-await.html" class="external" rel=" noopener">código-fonte</a>).</p>
</div>
-
+
<h3 id="but_how_does_it_work">Mas como isso funciona?</h3>
-
+
<div>
<p>Você notará que empacotamos o código dentro de uma função, e incluímos a palavra-chave <code>async</code> antes da palavra-chave<code>function</code>. Isso é necessário — você tem que criar uma função assíncrona para definir o bloco de código no qual você executará seu código assíncrono; como falamos mais cedo, <code>await</code> só funciona dentro de funções assíncronas.</p>
-
+
<p>Dentro da definição da função <code>myFetch()</code> você pode ver que o código se parece muito à versão anterior com promise, , mas tem algumas diferenças. Ao invés de precisar encadear um bloco <code>.then()</code> no final de cada método baseado em promise, você apenas adiciona a palavra-chave <code>await</code> antes de cada chamada de método, e então atribui o resultado a variável. A palavra-chave <code>await</code> faz com que o JavaScript pause seu código em tempo de execução nesta linha, não permitindo mais &nbsp;nenhum código ser executado nesse meio tempo até que a chamada de função assíncrona retorne seu resultado — muito útil se o código subsequente depender desse resultado!</p>
-
+
<p>Assim que estiver completo, seu código continua a ser executado começando na próxima linha. Por exemplo:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">let</span> response <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">fetch</span><span class="token punctuation">(</span><span class="token string">'coffee.jpg'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>A resposta retornada pela promise <code>fetch()</code> preenchida é atribuída a variável <code>response</code> quando a resposta estiver disponível, e o parser pausa nesta linha até que isso ocorra. Uma vez que a resposta está disponível, o parser move para a próxima linha, o qual cria o <code><a href="/pt-BR/docs/Web/API/Blob">Blob</a></code> fora dele. Esta linha também invoca um método assíncrono baseado em promise, assim podemos usar <code>await</code> aqui também. Quando o resultado da operação retorna, retornamos isso fora da funcão <code>myFetch()</code>.</p>
-
+
<p>Isso significa que quando nós chamamos a função <code>myFetch()</code>, isso retorna uma promise, então podemos encadear um <code>.then()</code> no final, dentro do qual lidamos com a exibição do blob na tela.</p>
-
+
<p>Provavelmente você já está pensando "isso é realmente demais!", e você está certo — menos blocos <code>.then()</code> para envolver o código, e quase sempre se parece com um código síncrono, por isso é muito intuitivo.</p>
</div>
-
+
<h3 id="adding_error_handling">Adicionando tratamento de erros</h3>
-
+
<div>
<p>E se você deseja adicionar tratamento de erros, você tem algumas opções.</p>
-
+
<p>Você pode usar uma estrutura <code><a href="/pt-BR/docs/Web/JavaScript/Reference/Statements/try...catch">try...catch</a></code> síncrona com <code>async</code>/<code>await</code>. Este exemplo se expande da primeira versão do código que mostramos acima:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">myFetch</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">try</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> response <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">fetch</span><span class="token punctuation">(</span><span class="token string">'coffee.jpg'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>response<span class="token punctuation">.</span>ok<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">Error</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">HTTP error! status: </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>response<span class="token punctuation">.</span>status<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
@@ -193,27 +193,27 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token keyword">let</span> image <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">(</span><span class="token string">'img'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
image<span class="token punctuation">.</span>src <span class="token operator">=</span> objectURL<span class="token punctuation">;</span>
document<span class="token punctuation">.</span>body<span class="token punctuation">.</span><span class="token function">appendChild</span><span class="token punctuation">(</span>image<span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token punctuation">}</span> <span class="token keyword">catch</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span> <span class="token punctuation">{</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
-
+
<span class="token function">myFetch</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>Ao bloco <code>catch() {}</code> é passado um objeto de erro, qual nós chamamos <code>e</code>; agora podemos registrar isso no console, e isso nos fornecerá uma mensagem de erro detalhada mostrando onde o erro foi gerado no código.</p>
-
+
<p>Se você quiser usar a segunda versão (refatorada) do código que mostramos acima, seria melhor apenas continuar a abordagem híbrida e encadear um bloco <code>.catch()</code> no final da chamada <code>.then()</code>, dessa forma:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">myFetch</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> response <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">fetch</span><span class="token punctuation">(</span><span class="token string">'coffee.jpg'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>response<span class="token punctuation">.</span>ok<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">Error</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">HTTP error! status: </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>response<span class="token punctuation">.</span>status<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">return</span> <span class="token keyword">await</span> response<span class="token punctuation">.</span><span class="token function">blob</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token punctuation">}</span>
-
+
<span class="token function">myFetch</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">blob</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> objectURL <span class="token operator">=</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token function">createObjectURL</span><span class="token punctuation">(</span>blob<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> image <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">(</span><span class="token string">'img'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
@@ -223,29 +223,29 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>Isso ocorre porque o bloco <code>.catch()</code> vai pegar os erros que ocorrem em ambos, na chamada de função com async e com cadeia de promises. Se você usou bloco <code>try</code>/<code>catch</code> aqui, você ainda pode obter erros não tratados na função <code>myFetch()</code> quando ela for chamada.</p>
-
+
<p>Você pode encontrar esses dois exemplos no GitHub:</p>
-
+
<ul>
<li><a href="https://mdn.github.io/learning-area/javascript/asynchronous/async-await/simple-fetch-async-await-try-catch.html" class="external" rel=" noopener">simple-fetch-async-await-try-catch.html</a> (veja <a href="https://github.com/mdn/learning-area/blob/master/javascript/asynchronous/async-await/simple-fetch-async-await-try-catch.html" class="external" rel=" noopener">código-fonte</a>)</li>
<li><a href="https://mdn.github.io/learning-area/javascript/asynchronous/async-await/simple-fetch-async-await-promise-catch.html" class="external" rel=" noopener">simple-fetch-async-await-promise-catch.html</a> (veja <a href="https://github.com/mdn/learning-area/blob/master/javascript/asynchronous/async-await/simple-fetch-async-await-promise-catch.html" class="external" rel=" noopener">código-fonte</a>)</li>
</ul>
</div>
-
+
<h2 id="awaiting_a_promise.all">Esperando um Promise.all()</h2>
-
+
<div>
<p>async/await é construído em cima de <a href="/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Promise">promises</a>, por isso é compatível com todos os recursos oferecidos por promises. Isso inclui <code><a href="/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Promise/all">Promise.all()</a></code> — você pode esperar felizmente uma chamada <code>Promise.all()</code> para obter todos os resultados retornados em uma variável de uma forma que se pareça com um código síncrono simples. De novo, vamos voltar para <a href="https://github.com/mdn/learning-area/blob/master/javascript/asynchronous/promises/promise-all.html" class="external" rel=" noopener">um exemplo que vimos em nosso artigo anterior</a>. Mantenha-o aberto em uma guia separada para que você possa comparar e contrastar com a nova versão mostrada abaixo.</p>
-
+
<p>Convertendo este para async/await (veja <a href="https://mdn.github.io/learning-area/javascript/asynchronous/async-await/promise-all-async-await.html" class="external" rel=" noopener">demonstração ao vivo</a> e <a href="https://github.com/mdn/learning-area/blob/master/javascript/asynchronous/async-await/promise-all-async-await.html" class="external" rel=" noopener">código-fonte</a>), isso agora parece assim:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">fetchAndDecode</span><span class="token punctuation">(</span><span class="token parameter">url<span class="token punctuation">,</span> type</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> response <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">fetch</span><span class="token punctuation">(</span>url<span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">let</span> content<span class="token punctuation">;</span>
-
+
<span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>response<span class="token punctuation">.</span>ok<span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">Error</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">HTTP error! status: </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>response<span class="token punctuation">.</span>status<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
@@ -255,58 +255,58 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
content <span class="token operator">=</span> <span class="token keyword">await</span> response<span class="token punctuation">.</span><span class="token function">text</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
-
+
<span class="token keyword">return</span> content<span class="token punctuation">;</span>
-
-
+
+
<span class="token punctuation">}</span>
-
+
<span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">displayContent</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> coffee <span class="token operator">=</span> <span class="token function">fetchAndDecode</span><span class="token punctuation">(</span><span class="token string">'coffee.jpg'</span><span class="token punctuation">,</span> <span class="token string">'blob'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> tea <span class="token operator">=</span> <span class="token function">fetchAndDecode</span><span class="token punctuation">(</span><span class="token string">'tea.jpg'</span><span class="token punctuation">,</span> <span class="token string">'blob'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> description <span class="token operator">=</span> <span class="token function">fetchAndDecode</span><span class="token punctuation">(</span><span class="token string">'description.txt'</span><span class="token punctuation">,</span> <span class="token string">'text'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">let</span> values <span class="token operator">=</span> <span class="token keyword">await</span> Promise<span class="token punctuation">.</span><span class="token function">all</span><span class="token punctuation">(</span><span class="token punctuation">[</span>coffee<span class="token punctuation">,</span> tea<span class="token punctuation">,</span> description<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">let</span> objectURL1 <span class="token operator">=</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token function">createObjectURL</span><span class="token punctuation">(</span>values<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> objectURL2 <span class="token operator">=</span> <span class="token constant">URL</span><span class="token punctuation">.</span><span class="token function">createObjectURL</span><span class="token punctuation">(</span>values<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> descText <span class="token operator">=</span> values<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">let</span> image1 <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">(</span><span class="token string">'img'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> image2 <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">(</span><span class="token string">'img'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
image1<span class="token punctuation">.</span>src <span class="token operator">=</span> objectURL1<span class="token punctuation">;</span>
image2<span class="token punctuation">.</span>src <span class="token operator">=</span> objectURL2<span class="token punctuation">;</span>
document<span class="token punctuation">.</span>body<span class="token punctuation">.</span><span class="token function">appendChild</span><span class="token punctuation">(</span>image1<span class="token punctuation">)</span><span class="token punctuation">;</span>
document<span class="token punctuation">.</span>body<span class="token punctuation">.</span><span class="token function">appendChild</span><span class="token punctuation">(</span>image2<span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">let</span> para <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">(</span><span class="token string">'p'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
para<span class="token punctuation">.</span>textContent <span class="token operator">=</span> descText<span class="token punctuation">;</span>
document<span class="token punctuation">.</span>body<span class="token punctuation">.</span><span class="token function">appendChild</span><span class="token punctuation">(</span>para<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
-
+
<span class="token function">displayContent</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>e<span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>Você notará que a função <code>fetchAndDecode()</code> foi convertida facilmente em uma função assíncrona com apenas algumas alterações. Veja a linha do <code>Promise.all()</code>:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">let</span> values <span class="token operator">=</span> <span class="token keyword">await</span> Promise<span class="token punctuation">.</span><span class="token function">all</span><span class="token punctuation">(</span><span class="token punctuation">[</span>coffee<span class="token punctuation">,</span> tea<span class="token punctuation">,</span> description<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>Usando <code>await</code> aqui podemos obter todos os resultados das três promises retornadas no array <code>values</code>, quando todos eles estão disponíveis, de uma forma que se parece muito com o código síncrono. Tivemos que envolver todo o código em uma nova função assíncrona, <code>displayContent()</code>, e não reduzimos o código em muitas linhas, mas ser capaz de mover a maior parte do código para fora do bloco <code>.then()</code> fornece uma simplificação agradável e útil, deixando-nos com um programa muito mais legível.</p>
-
+
<p>Para tratamento de erros, nós incluímos um bloco <code>.catch()</code> no nossa chamada <code>displayContent()</code>; isso vai lidar com os erros que ocorrem em ambas as funções.</p>
-
+
<div class="notecard note">
<p><strong>Nota</strong>: Também é possível usar um bloco <code><a href="/pt-BR/docs/Web/JavaScript/Reference/Statements/try...catch#the_finally_clause">finally</a></code> síncrono na função assíncrona, no lugar de um bloco assíncrono<code><a href="/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally">.finally()</a></code>, para mostrar um relatório final sobre como foi a operação — você pode ver isso em ação no nosso <a href="https://mdn.github.io/learning-area/javascript/asynchronous/async-await/promise-finally-async-await.html" class="external" rel=" noopener">exemplo ao vivo</a> (veja também o <a href="https://github.com/mdn/learning-area/blob/master/javascript/asynchronous/async-await/promise-finally-async-await.html" class="external" rel=" noopener">código-fonte</a>).</p>
</div>
</div>
-
+
<h2 id="handling_asyncawait_slowdown">Tratando lentidão com async/await</h2>
-
+
<div>
<p>Async/await faz seu código parecer síncrono e, de certa forma, faz com que se comporte de maneira mais síncrona. A palavra-chave <code>await</code> bloqueia a execução de todo o código que o segue até que a promise seja cumprida, exatamente como faria com uma operação síncrona. Ele permite que outras tarefas continuem sendo executadas enquanto isso, mas o código com await é bloqueado. Por exemplo:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">makeResult</span><span class="token punctuation">(</span><span class="token parameter">items</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> newArr <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">let</span> i<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> items<span class="token punctuation">.</span>length<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
@@ -314,18 +314,18 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token punctuation">}</span>
<span class="token keyword">return</span> newArr<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
-
+
<span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">getResult</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> result <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">makeResult</span><span class="token punctuation">(</span>items<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// Blocked on this line</span>
<span class="token function">useThatResult</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// Will not be executed before makeResult() is done</span>
<span class="token punctuation">}</span>
-
+
</code></pre></div>
-
+
<p>Como resultado, seu código pode ser retardado por um número significativo de promises aguardadas acontecendo uma após a outra. Cada <code>await</code> vai esperar que o anterior termine, ao passo que, na verdade, o que você pode querer é que as promises comecem a ser processadas simultaneamente, como fariam se não estivéssemos usando async/await.</p>
-
+
<p>Vejamos esses dois exemplos — <a href="https://mdn.github.io/learning-area/javascript/asynchronous/async-await/slow-async-await.html" class="external" rel=" noopener">slow-async-await.html</a> (veja <a href="https://github.com/mdn/learning-area/blob/master/javascript/asynchronous/async-await/slow-async-await.html" class="external" rel=" noopener">código-fonte</a>) e <a href="https://mdn.github.io/learning-area/javascript/asynchronous/async-await/fast-async-await.html" class="external" rel=" noopener">fast-async-await.html</a> (veja <a href="https://github.com/mdn/learning-area/blob/master/javascript/asynchronous/async-await/fast-async-await.html" class="external" rel=" noopener">código-fonte</a>). Ambos começam com uma função promise personalizada que simula um processo assíncrono com uma chamada <code><a href="/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout">setTimeout()</a></code>:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">function</span> <span class="token function">timeoutPromise</span><span class="token punctuation">(</span><span class="token parameter">interval</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">resolve<span class="token punctuation">,</span> reject</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
@@ -333,58 +333,58 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token punctuation">}</span><span class="token punctuation">,</span> interval<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>Cada um deles inclui uma função assíncrona <code>timeTest()</code> que espera três chamadas <code>timeoutPromise()</code>:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">timeTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token operator">...</span>
<span class="token punctuation">}</span></code></pre></div>
-
+
<p>Cada um termina registrando um horário de início, vendo quanto tempo a promise <code>timeTest()</code> leva para completar, em seguida, registrando um horário de término e relatando quanto tempo a operação levou no total:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">let</span> startTime <span class="token operator">=</span> Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">timeTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token keyword">let</span> finishTime <span class="token operator">=</span> Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">let</span> timeTaken <span class="token operator">=</span> finishTime <span class="token operator">-</span> startTime<span class="token punctuation">;</span>
<span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">"Time taken in milliseconds: "</span> <span class="token operator">+</span> timeTaken<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span></code></pre></div>
-
+
<p>Isso é a função <code>timeTest()</code> que difere em cada caso.</p>
-
+
<p>No exemplo <code>slow-async-await.html</code>, <code>timeTest()</code> se parece com isso:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">timeTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">await</span> <span class="token function">timeoutPromise</span><span class="token punctuation">(</span><span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">await</span> <span class="token function">timeoutPromise</span><span class="token punctuation">(</span><span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">await</span> <span class="token function">timeoutPromise</span><span class="token punctuation">(</span><span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
-
+
<p>Aqui esperamos diretamente todas as três chamadas <code>timeoutPromise()</code>, fazendo cada uma a cada 3 segundos. Cada chamada subsequente é forçada a esperar até que a última termine — se você executar o primeiro exemplo, você verá a caixa de alerta relatando um tempo total de execução de cerca de 9 segundos.</p>
-
+
<p>No exemplo <code>fast-async-await.html</code>, <code>timeTest()</code> se parece com isso:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">timeTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">const</span> timeoutPromise1 <span class="token operator">=</span> <span class="token function">timeoutPromise</span><span class="token punctuation">(</span><span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> timeoutPromise2 <span class="token operator">=</span> <span class="token function">timeoutPromise</span><span class="token punctuation">(</span><span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> timeoutPromise3 <span class="token operator">=</span> <span class="token function">timeoutPromise</span><span class="token punctuation">(</span><span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">await</span> timeoutPromise1<span class="token punctuation">;</span>
<span class="token keyword">await</span> timeoutPromise2<span class="token punctuation">;</span>
<span class="token keyword">await</span> timeoutPromise3<span class="token punctuation">;</span>
<span class="token punctuation">}</span></code></pre></div>
-
+
<p>Aqui nós armazenamos os três objetos <code>Promise</code> em variáveis, que tem o efeito de desencadear seus processos associados, todos rodando simultaneamente.</p>
-
+
<p>A seguir, aguardamos seus resultados — porque todas as promises começaram a ser processadas essencialmente ao mesmo tempo, as promises serão cumpridas todas ao mesmo tempo; ao executar o segundo exemplo, você verá a caixa de alerta relatando um tempo total de execução de pouco mais de 3 segundos!</p>
</div>
-
+
<h3 id="handling_errors">Tratamento de erros</h3>
-
+
<div>
<p>Há um problema com o padrão acima, no entanto — pode levar a erros não tratados.</p>
-
+
<p>Vamos atualizar os exemplos anteriores, desta vez adicionando uma promise rejeitada e uma declaração <code>catch</code> no final:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">function</span> <span class="token function">timeoutPromiseResolve</span><span class="token punctuation">(</span><span class="token parameter">interval</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">resolve<span class="token punctuation">,</span> reject</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
@@ -392,7 +392,7 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token punctuation">}</span><span class="token punctuation">,</span> interval<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">function</span> <span class="token function">timeoutPromiseReject</span><span class="token punctuation">(</span><span class="token parameter">interval</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">resolve<span class="token punctuation">,</span> reject</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
@@ -400,13 +400,13 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token punctuation">}</span><span class="token punctuation">,</span> interval<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">timeTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">await</span> <span class="token function">timeoutPromiseResolve</span><span class="token punctuation">(</span><span class="token number">5000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">await</span> <span class="token function">timeoutPromiseReject</span><span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">await</span> <span class="token function">timeoutPromiseResolve</span><span class="token punctuation">(</span><span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
-
+
<span class="token keyword">let</span> startTime <span class="token operator">=</span> Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">timeTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token parameter">e</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
@@ -415,11 +415,11 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token keyword">let</span> timeTaken <span class="token operator">=</span> finishTime <span class="token operator">-</span> startTime<span class="token punctuation">;</span>
<span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">"Time taken in milliseconds: "</span> <span class="token operator">+</span> timeTaken<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span></code></pre></div>
-
+
<p>No exemplo acima, o erro é tratado corretamente, e o alerta aparece após aproximadamente 7 segundos.</p>
-
+
<p>Agora no segundo padrão:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">function</span> <span class="token function">timeoutPromiseResolve</span><span class="token punctuation">(</span><span class="token parameter">interval</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">resolve<span class="token punctuation">,</span> reject</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
@@ -427,7 +427,7 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token punctuation">}</span><span class="token punctuation">,</span> interval<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">function</span> <span class="token function">timeoutPromiseReject</span><span class="token punctuation">(</span><span class="token parameter">interval</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">resolve<span class="token punctuation">,</span> reject</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
@@ -435,17 +435,17 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token punctuation">}</span><span class="token punctuation">,</span> interval<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">timeTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">const</span> timeoutPromiseResolve1 <span class="token operator">=</span> <span class="token function">timeoutPromiseResolve</span><span class="token punctuation">(</span><span class="token number">5000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> timeoutPromiseReject2 <span class="token operator">=</span> <span class="token function">timeoutPromiseReject</span><span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> timeoutPromiseResolve3 <span class="token operator">=</span> <span class="token function">timeoutPromiseResolve</span><span class="token punctuation">(</span><span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">await</span> timeoutPromiseResolve1<span class="token punctuation">;</span>
<span class="token keyword">await</span> timeoutPromiseReject2<span class="token punctuation">;</span>
<span class="token keyword">await</span> timeoutPromiseResolve3<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
-
+
<span class="token keyword">let</span> startTime <span class="token operator">=</span> Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">timeTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token parameter">e</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
@@ -454,11 +454,11 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token keyword">let</span> timeTaken <span class="token operator">=</span> finishTime <span class="token operator">-</span> startTime<span class="token punctuation">;</span>
<span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">"Time taken in milliseconds: "</span> <span class="token operator">+</span> timeTaken<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span></code></pre></div>
-
+
<p>Neste exemplo, temos um erro não tratado no console (depois de 2 segundos), e o alerta aparece após aproximadamente 5 segundos.</p>
-
- <p>Para iniciar as promises em paralelo e detectar o erro corretamente, nós poderíamos usar <code>Promise.all()</code>, como discutido anteriormente:</p>
-
+
+ <p>Para iniciar as promises em paralelo e detectar o erro corretamente, nós poderíamos usar <code>Promise.all()</code>, como discutido anteriormente:</p>
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">function</span> <span class="token function">timeoutPromiseResolve</span><span class="token punctuation">(</span><span class="token parameter">interval</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">resolve<span class="token punctuation">,</span> reject</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
@@ -466,7 +466,7 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token punctuation">}</span><span class="token punctuation">,</span> interval<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">function</span> <span class="token function">timeoutPromiseReject</span><span class="token punctuation">(</span><span class="token parameter">interval</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">resolve<span class="token punctuation">,</span> reject</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
@@ -474,16 +474,16 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token punctuation">}</span><span class="token punctuation">,</span> interval<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">timeTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">const</span> timeoutPromiseResolve1 <span class="token operator">=</span> <span class="token function">timeoutPromiseResolve</span><span class="token punctuation">(</span><span class="token number">5000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> timeoutPromiseReject2 <span class="token operator">=</span> <span class="token function">timeoutPromiseReject</span><span class="token punctuation">(</span><span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> timeoutPromiseResolve3 <span class="token operator">=</span> <span class="token function">timeoutPromiseResolve</span><span class="token punctuation">(</span><span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
-
+
<span class="token keyword">const</span> results <span class="token operator">=</span> <span class="token keyword">await</span> Promise<span class="token punctuation">.</span><span class="token function">all</span><span class="token punctuation">(</span><span class="token punctuation">[</span>timeoutPromiseResolve1<span class="token punctuation">,</span> timeoutPromiseReject2<span class="token punctuation">,</span> timeoutPromiseResolve3<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">return</span> results<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
-
+
<span class="token keyword">let</span> startTime <span class="token operator">=</span> Date<span class="token punctuation">.</span><span class="token function">now</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">timeTest</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token parameter">e</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
@@ -492,17 +492,17 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token keyword">let</span> timeTaken <span class="token operator">=</span> finishTime <span class="token operator">-</span> startTime<span class="token punctuation">;</span>
<span class="token function">alert</span><span class="token punctuation">(</span><span class="token string">"Time taken in milliseconds: "</span> <span class="token operator">+</span> timeTaken<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span></code></pre></div>
-
+
<p>Neste exemplo, o erro é tratado corretamente após aproximadamente 2 segundos e também vemos o alerta após aproximadamente 2 segundos.</p>
-
+
<p>A <code>Promise.all()</code> rejeita quando qualquer uma das promises de entrada é rejeitada. Se você deseja que todas as promises sejam cumpridas e, em seguida, usar alguns de seus valores retornados, mesmo quando alguns deles são rejeitados, você pode usar <a href="/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled"><code>Promise.allSettled()</code></a>.</p>
</div>
-
+
<h2 id="asyncawait_class_methods">Async/await em métodos de classe</a></h2>
-
+
<div>
<p>Como nota final, antes de prosseguirmos, você pode até adicionar <code>async</code> na frente de métodos de classe / objeto para fazê-los retornar promises, e <code>await</code> promises dentro deles. Dê uma olhada no artigo <a href="/pt-BR/docs/Learn/JavaScript/Objects/Inheritance#ecmascript_2015_classes">Código de classe ES que vimos em nosso JavaScript orientado a objetos</a>. em seguida, olhe para nossa versão modificada com um método <code>async</code>:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code><span class="token keyword">class</span> <span class="token class-name">Person</span> <span class="token punctuation">{</span>
<span class="token function">constructor</span><span class="token punctuation">(</span><span class="token parameter">first<span class="token punctuation">,</span> last<span class="token punctuation">,</span> age<span class="token punctuation">,</span> gender<span class="token punctuation">,</span> interests</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">this</span><span class="token punctuation">.</span>name <span class="token operator">=</span> <span class="token punctuation">{</span>
@@ -513,28 +513,28 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<span class="token keyword">this</span><span class="token punctuation">.</span>gender <span class="token operator">=</span> gender<span class="token punctuation">;</span>
<span class="token keyword">this</span><span class="token punctuation">.</span>interests <span class="token operator">=</span> interests<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
-
+
<span class="token keyword">async</span> <span class="token function">greeting</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> <span class="token keyword">await</span> Promise<span class="token punctuation">.</span><span class="token function">resolve</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">Hi! I'm </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span><span class="token keyword">this</span><span class="token punctuation">.</span>name<span class="token punctuation">.</span>first<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
-
+
<span class="token function">farewell</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span><span class="token keyword">this</span><span class="token punctuation">.</span>name<span class="token punctuation">.</span>first<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string"> has left the building. Bye for now!</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
-
+
<span class="token keyword">let</span> han <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Person</span><span class="token punctuation">(</span><span class="token string">'Han'</span><span class="token punctuation">,</span> <span class="token string">'Solo'</span><span class="token punctuation">,</span> <span class="token number">25</span><span class="token punctuation">,</span> <span class="token string">'male'</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string">'Smuggling'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
-
+
<p>O primeiro método da classe agora pode ser usado assim:</p>
-
+
<div class="code-example"><pre class="brush: js notranslate"><code>han<span class="token punctuation">.</span><span class="token function">greeting</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span>console<span class="token punctuation">.</span>log<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre></div>
</div>
-
+
<h2 id="browser_support"><a href="#browser_support" title="Permalink to Browser support">Suporte de navegador</a></h2>
-
+
<div>
<p>Uma consideração ao decidir se deve usar async/await é o suporte para navegadores mais antigos. Eles estão disponíveis em versões modernas da maioria dos navegadores, o mesmo que promises; os principais problemas de suporte vêm com o Internet Explorer e o Opera Mini.</p>
-
+
<p>Se você deseja usar async/await, mas está preocupado com o suporte a navegadores mais antigos, pode considerar o uso da biblioteca <a href="https://babeljs.io/" class="external" rel=" noopener">BabelJS</a> — isso permite que você escreva seus aplicativos usando o JavaScript mais recente e deixe Babel descobrir quais mudanças, se houver, são necessárias para os navegadores de seu usuário. Ao encontrar um navegador que não suporta async/await, o polyfill do Babel pode fornecer automaticamente substitutos que funcionam em navegadores mais antigos.</p>
</div>
@@ -553,4 +553,4 @@ original_slug: Learn/JavaScript/Asynchronous/Async_await
<li><a href="/pt-BR/docs/Learn/JavaScript/Asynchronous/Promises">Programação elegante com Promises</a></li>
<li><a href="/pt-BR/docs/Learn/JavaScript/Asynchronous/Choosing_the_right_approach">Escolhendo a abordagem correta</a></li>
</ul>
-</div> \ No newline at end of file
+</div>
diff --git a/files/pt-br/learn/javascript/asynchronous/timeouts_and_intervals/index.html b/files/pt-br/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.html
index f483c33937..07c4f43719 100644
--- a/files/pt-br/learn/javascript/asynchronous/timeouts_and_intervals/index.html
+++ b/files/pt-br/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.html
@@ -1,7 +1,8 @@
---
title: Timeouts e intervalos
-slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+slug: conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df
translation_of: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+original_slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
---
<div>{{LearnSidebar}}</div>
diff --git a/files/ru/_redirects.txt b/files/ru/_redirects.txt
index aa50f26b06..377cf27043 100644
--- a/files/ru/_redirects.txt
+++ b/files/ru/_redirects.txt
@@ -221,7 +221,10 @@
/ru/docs/Learn/HTML/Введение_в_HTML/Структура_документа_и_веб-сайта /ru/docs/Learn/HTML/Introduction_to_HTML/Document_and_website_structure
/ru/docs/Learn/HTML/Рецепты /ru/docs/Learn/HTML/Howto
/ru/docs/Learn/How_the_Internet_works /ru/docs/Learn/Common_questions/How_does_the_Internet_work
-/ru/docs/Learn/JavaScript/Asynchronous/Таймауты_и_интервалы /ru/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+/ru/docs/Learn/JavaScript/Asynchronous/Async_await /ru/docs/Learn/JavaScript/Asynchronous/Promises
+/ru/docs/Learn/JavaScript/Asynchronous/Concepts /ru/docs/conflicting/Learn/JavaScript/Asynchronous/Introducing
+/ru/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals /ru/docs/conflicting/Learn/JavaScript/Asynchronous
+/ru/docs/Learn/JavaScript/Asynchronous/Таймауты_и_интервалы /ru/docs/conflicting/Learn/JavaScript/Asynchronous
/ru/docs/Learn/JavaScript/Building_blocks/События /ru/docs/Learn/JavaScript/Building_blocks/Events
/ru/docs/Learn/JavaScript/Objects/Inheritance /ru/docs/Learn/JavaScript/Objects/Classes_in_JavaScript
/ru/docs/Learn/JavaScript/Objects/Object-oriented_JS /ru/docs/conflicting/Learn/JavaScript/Objects/Classes_in_JavaScript
diff --git a/files/ru/_wikihistory.json b/files/ru/_wikihistory.json
index 4a8d00b762..d6c88836f4 100644
--- a/files/ru/_wikihistory.json
+++ b/files/ru/_wikihistory.json
@@ -3137,21 +3137,6 @@
"Sheppy"
]
},
- "Learn/JavaScript/Asynchronous/Async_await": {
- "modified": "2020-12-10T12:33:00.159Z",
- "contributors": [
- "WhoRlyCares",
- "Bucido"
- ]
- },
- "Learn/JavaScript/Asynchronous/Concepts": {
- "modified": "2020-12-02T05:41:10.583Z",
- "contributors": [
- "haltaction",
- "KrasnovaM",
- "snayp"
- ]
- },
"Learn/JavaScript/Asynchronous/Introducing": {
"modified": "2020-12-09T10:05:03.071Z",
"contributors": [
@@ -3165,11 +3150,11 @@
"MaxYenot"
]
},
- "Learn/JavaScript/Asynchronous/Timeouts_and_intervals": {
- "modified": "2020-12-09T10:32:13.319Z",
+ "Learn/JavaScript/Asynchronous/Promises": {
+ "modified": "2020-12-10T12:33:00.159Z",
"contributors": [
"WhoRlyCares",
- "velheor24"
+ "Bucido"
]
},
"Learn/JavaScript/Building_blocks": {
@@ -23981,6 +23966,21 @@
"TuchaNK"
]
},
+ "conflicting/Learn/JavaScript/Asynchronous": {
+ "modified": "2020-12-09T10:32:13.319Z",
+ "contributors": [
+ "WhoRlyCares",
+ "velheor24"
+ ]
+ },
+ "conflicting/Learn/JavaScript/Asynchronous/Introducing": {
+ "modified": "2020-12-02T05:41:10.583Z",
+ "contributors": [
+ "haltaction",
+ "KrasnovaM",
+ "snayp"
+ ]
+ },
"conflicting/Learn/JavaScript/Objects": {
"modified": "2019-06-04T15:16:30.349Z",
"contributors": [
diff --git a/files/ru/learn/javascript/asynchronous/timeouts_and_intervals/index.html b/files/ru/conflicting/learn/javascript/asynchronous/index.html
index 19019a19a9..f87839f2ff 100644
--- a/files/ru/learn/javascript/asynchronous/timeouts_and_intervals/index.html
+++ b/files/ru/conflicting/learn/javascript/asynchronous/index.html
@@ -1,8 +1,8 @@
---
title: 'Объединённый асинхронный JavaScript: Таймауты и интервалы'
-slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+slug: conflicting/Learn/JavaScript/Asynchronous
translation_of: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
-original_slug: Learn/JavaScript/Asynchronous/Таймауты_и_интервалы
+original_slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
---
<div>{{LearnSidebar}}</div>
diff --git a/files/ru/learn/javascript/asynchronous/concepts/index.html b/files/ru/conflicting/learn/javascript/asynchronous/introducing/index.html
index fe4e6c7343..1257b751b8 100644
--- a/files/ru/learn/javascript/asynchronous/concepts/index.html
+++ b/files/ru/conflicting/learn/javascript/asynchronous/introducing/index.html
@@ -1,6 +1,6 @@
---
title: Основные понятия асинхронного программирования
-slug: Learn/JavaScript/Asynchronous/Concepts
+slug: conflicting/Learn/JavaScript/Asynchronous/Introducing
tags:
- JavaScript
- Promises
@@ -9,6 +9,7 @@ tags:
- блокировки
- потоки
translation_of: Learn/JavaScript/Asynchronous/Concepts
+original_slug: Learn/JavaScript/Asynchronous/Concepts
---
<div>{{LearnSidebar}}{{NextMenu("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous")}}</div>
diff --git a/files/ru/learn/javascript/asynchronous/async_await/index.html b/files/ru/learn/javascript/asynchronous/promises/index.html
index e64c9cc30b..4bf8481105 100644
--- a/files/ru/learn/javascript/asynchronous/async_await/index.html
+++ b/files/ru/learn/javascript/asynchronous/promises/index.html
@@ -1,11 +1,12 @@
---
title: Making asynchronous programming easier with async and await
-slug: Learn/JavaScript/Asynchronous/Async_await
+slug: Learn/JavaScript/Asynchronous/Promises
tags:
- Асинхронность
- Гайд
- Для новичков
translation_of: Learn/JavaScript/Asynchronous/Async_await
+original_slug: Learn/JavaScript/Asynchronous/Async_await
---
<div>{{LearnSidebar}}</div>
diff --git a/files/zh-cn/_redirects.txt b/files/zh-cn/_redirects.txt
index 6789bcbf8c..1b57d8f385 100644
--- a/files/zh-cn/_redirects.txt
+++ b/files/zh-cn/_redirects.txt
@@ -1094,6 +1094,10 @@
/zh-CN/docs/Learn/HTML/Forms/Your_first_HTML_form /zh-CN/docs/Learn/Forms/Your_first_form
/zh-CN/docs/Learn/HTML/Multimedia_and_embedding/其他嵌入技术 /zh-CN/docs/Learn/HTML/Multimedia_and_embedding/Other_embedding_technologies
/zh-CN/docs/Learn/HTML/Multimedia_and_embedding/在网页中添加矢量图形 /zh-CN/docs/Learn/HTML/Multimedia_and_embedding/Adding_vector_graphics_to_the_Web
+/zh-CN/docs/Learn/JavaScript/Asynchronous/Async_await /zh-CN/docs/conflicting/Learn/JavaScript/Asynchronous/Promises
+/zh-CN/docs/Learn/JavaScript/Asynchronous/Choosing_the_right_approach /zh-CN/docs/conflicting/Learn/JavaScript/Asynchronous
+/zh-CN/docs/Learn/JavaScript/Asynchronous/Concepts /zh-CN/docs/conflicting/Learn/JavaScript/Asynchronous/Introducing
+/zh-CN/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals /zh-CN/docs/conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df
/zh-CN/docs/Learn/JavaScript/First_steps/变量 /zh-CN/docs/Learn/JavaScript/First_steps/Variables
/zh-CN/docs/Learn/JavaScript/First_steps/第一点 /zh-CN/docs/Learn/JavaScript/First_steps/A_first_splash
/zh-CN/docs/Learn/JavaScript/Objects/Inheritance /zh-CN/docs/Learn/JavaScript/Objects/Classes_in_JavaScript
@@ -1273,6 +1277,7 @@
/zh-CN/docs/Web/API/Document/onfullscreenchange /zh-CN/docs/conflicting/Web/API/Document/fullscreenchange_event
/zh-CN/docs/Web/API/Document/onfullscreenerror /zh-CN/docs/Web/API/Document/fullscreenerror_event
/zh-CN/docs/Web/API/Document/onreadystatechange /en-US/docs/Web/API/Document/readystatechange_event
+/zh-CN/docs/Web/API/Document/onvisibilitychange /zh-CN/docs/conflicting/Web/API/Document/visibilitychange_event
/zh-CN/docs/Web/API/Document/rouchmove_event /zh-CN/docs/Web/API/Document/touchmove_event
/zh-CN/docs/Web/API/DocumentOrShadowRoot/activeElement /zh-CN/docs/Web/API/Document/activeElement
/zh-CN/docs/Web/API/DocumentOrShadowRoot/elementFromPoint /zh-CN/docs/Web/API/Document/elementFromPoint
@@ -1466,6 +1471,7 @@
/zh-CN/docs/Web/API/ParentNode.childElementCount /zh-CN/docs/Web/API/Element/childElementCount
/zh-CN/docs/Web/API/ParentNode/childElementCount /zh-CN/docs/Web/API/Element/childElementCount
/zh-CN/docs/Web/API/Performance.now() /zh-CN/docs/Web/API/Performance/now
+/zh-CN/docs/Web/API/Performance/onresourcetimingbufferfull /zh-CN/docs/Web/API/Performance/resourcetimingbufferfull_event
/zh-CN/docs/Web/API/Performance/内存 /zh-CN/docs/Web/API/Performance/memory
/zh-CN/docs/Web/API/Position /zh-CN/docs/Web/API/GeolocationPosition
/zh-CN/docs/Web/API/Position/coords /zh-CN/docs/Web/API/GeolocationPosition/coords
@@ -1599,6 +1605,7 @@
/zh-CN/docs/Web/API/Window/crypto /zh-CN/docs/Web/API/crypto_property
/zh-CN/docs/Web/API/Window/minimize /zh-CN/docs/conflicting/Web/API/Window
/zh-CN/docs/Web/API/Window/mozAnimationStartTIme /zh-CN/docs/Web/API/Animation/startTime
+/zh-CN/docs/Web/API/Window/onappinstalled /zh-CN/docs/Web/API/Window/appinstalled_event
/zh-CN/docs/Web/API/Window/onbeforeunload /zh-CN/docs/Web/API/WindowEventHandlers/onbeforeunload
/zh-CN/docs/Web/API/Window/ongamepadconnected /zh-CN/docs/conflicting/Web/API/Window/gamepadconnected_event
/zh-CN/docs/Web/API/Window/ongamepaddisconnected /zh-CN/docs/Web/API/Window/gamepaddisconnected_event
@@ -2284,12 +2291,12 @@
/zh-CN/docs/learn/JavaScript/Building_blocks/事件 /zh-CN/docs/Learn/JavaScript/Building_blocks/Events
/zh-CN/docs/learn/JavaScript/Building_blocks/相片走廊 /zh-CN/docs/Learn/JavaScript/Building_blocks/Image_gallery
/zh-CN/docs/learn/JavaScript/异步 /zh-CN/docs/Learn/JavaScript/Asynchronous
-/zh-CN/docs/learn/JavaScript/异步/Async_await /zh-CN/docs/Learn/JavaScript/Asynchronous/Async_await
-/zh-CN/docs/learn/JavaScript/异步/Choosing_the_right_approach /zh-CN/docs/Learn/JavaScript/Asynchronous/Choosing_the_right_approach
+/zh-CN/docs/learn/JavaScript/异步/Async_await /zh-CN/docs/conflicting/Learn/JavaScript/Asynchronous/Promises
+/zh-CN/docs/learn/JavaScript/异步/Choosing_the_right_approach /zh-CN/docs/conflicting/Learn/JavaScript/Asynchronous
/zh-CN/docs/learn/JavaScript/异步/Promises语法 /zh-CN/docs/Learn/JavaScript/Asynchronous/Promises
-/zh-CN/docs/learn/JavaScript/异步/概念 /zh-CN/docs/Learn/JavaScript/Asynchronous/Concepts
+/zh-CN/docs/learn/JavaScript/异步/概念 /zh-CN/docs/conflicting/Learn/JavaScript/Asynchronous/Introducing
/zh-CN/docs/learn/JavaScript/异步/简介 /zh-CN/docs/Learn/JavaScript/Asynchronous/Introducing
-/zh-CN/docs/learn/JavaScript/异步/超时和间隔 /zh-CN/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+/zh-CN/docs/learn/JavaScript/异步/超时和间隔 /zh-CN/docs/conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df
/zh-CN/docs/learn/Performance/CSS_performance /zh-CN/docs/Learn/Performance/CSS
/zh-CN/docs/learn/Performance/dns-prefetch /zh-CN/docs/Web/Performance/dns-prefetch
/zh-CN/docs/learn/Performance/感知性能 /zh-CN/docs/Learn/Performance/perceived_performance
diff --git a/files/zh-cn/_wikihistory.json b/files/zh-cn/_wikihistory.json
index 04de070975..79ea90a611 100644
--- a/files/zh-cn/_wikihistory.json
+++ b/files/zh-cn/_wikihistory.json
@@ -4173,40 +4173,6 @@
"oceanMIH"
]
},
- "Learn/JavaScript/Asynchronous/Async_await": {
- "modified": "2020-12-08T06:58:32.883Z",
- "contributors": [
- "byrde",
- "woniuxingdong",
- "qwei",
- "plainnany",
- "jakio6",
- "awarmy",
- "cochn",
- "wangfangping"
- ]
- },
- "Learn/JavaScript/Asynchronous/Choosing_the_right_approach": {
- "modified": "2020-12-08T07:27:41.218Z",
- "contributors": [
- "byrde",
- "icetea_cover",
- "rubyKC",
- "shangruitong",
- "PYGC",
- "wangfangping",
- "tjls"
- ]
- },
- "Learn/JavaScript/Asynchronous/Concepts": {
- "modified": "2020-07-16T22:33:29.726Z",
- "contributors": [
- "alice201601",
- "grape",
- "HermitSun",
- "oceanMIH"
- ]
- },
"Learn/JavaScript/Asynchronous/Introducing": {
"modified": "2020-12-09T00:17:16.227Z",
"contributors": [
@@ -4236,22 +4202,6 @@
"zijieee"
]
},
- "Learn/JavaScript/Asynchronous/Timeouts_and_intervals": {
- "modified": "2020-08-14T06:09:20.310Z",
- "contributors": [
- "Pada",
- "You2er",
- "WinterCicada",
- "zhangbig0",
- "mizhon",
- "yuqing521",
- "Alendia",
- "grape",
- "wangfangping",
- "puddlejumper26",
- "oceanMIH"
- ]
- },
"Learn/JavaScript/Building_blocks/Events": {
"modified": "2020-08-04T06:06:58.173Z",
"contributors": [
@@ -11302,12 +11252,6 @@
"githubyangwei"
]
},
- "Web/API/Document/onvisibilitychange": {
- "modified": "2020-10-15T22:25:06.098Z",
- "contributors": [
- "wangzhongchunongithub"
- ]
- },
"Web/API/Document/open": {
"modified": "2020-10-15T21:52:24.168Z",
"contributors": [
@@ -18297,7 +18241,7 @@
"ziyunfei"
]
},
- "Web/API/Performance/onresourcetimingbufferfull": {
+ "Web/API/Performance/resourcetimingbufferfull_event": {
"modified": "2019-03-23T22:09:51.120Z",
"contributors": [
"Pada"
@@ -22603,6 +22547,13 @@
"ziyunfei"
]
},
+ "Web/API/Window/appinstalled_event": {
+ "modified": "2019-03-18T21:40:44.436Z",
+ "contributors": [
+ "Aaron_Zhung",
+ "echoArray"
+ ]
+ },
"Web/API/Window/applicationCache": {
"modified": "2019-03-23T23:31:44.274Z",
"contributors": [
@@ -23104,13 +23055,6 @@
"charlie"
]
},
- "Web/API/Window/onappinstalled": {
- "modified": "2019-03-18T21:40:44.436Z",
- "contributors": [
- "Aaron_Zhung",
- "echoArray"
- ]
- },
"Web/API/Window/onbeforeinstallprompt": {
"modified": "2019-03-23T22:11:25.289Z",
"contributors": [
@@ -46637,6 +46581,56 @@
"shenhao"
]
},
+ "conflicting/Learn/JavaScript/Asynchronous": {
+ "modified": "2020-12-08T07:27:41.218Z",
+ "contributors": [
+ "byrde",
+ "icetea_cover",
+ "rubyKC",
+ "shangruitong",
+ "PYGC",
+ "wangfangping",
+ "tjls"
+ ]
+ },
+ "conflicting/Learn/JavaScript/Asynchronous/Introducing": {
+ "modified": "2020-07-16T22:33:29.726Z",
+ "contributors": [
+ "alice201601",
+ "grape",
+ "HermitSun",
+ "oceanMIH"
+ ]
+ },
+ "conflicting/Learn/JavaScript/Asynchronous/Promises": {
+ "modified": "2020-12-08T06:58:32.883Z",
+ "contributors": [
+ "byrde",
+ "woniuxingdong",
+ "qwei",
+ "plainnany",
+ "jakio6",
+ "awarmy",
+ "cochn",
+ "wangfangping"
+ ]
+ },
+ "conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df": {
+ "modified": "2020-08-14T06:09:20.310Z",
+ "contributors": [
+ "Pada",
+ "You2er",
+ "WinterCicada",
+ "zhangbig0",
+ "mizhon",
+ "yuqing521",
+ "Alendia",
+ "grape",
+ "wangfangping",
+ "puddlejumper26",
+ "oceanMIH"
+ ]
+ },
"conflicting/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents": {
"modified": "2019-03-23T23:14:19.406Z",
"contributors": [
@@ -46836,6 +46830,12 @@
"sunnylost"
]
},
+ "conflicting/Web/API/Document/visibilitychange_event": {
+ "modified": "2020-10-15T22:25:06.098Z",
+ "contributors": [
+ "wangzhongchunongithub"
+ ]
+ },
"conflicting/Web/API/DocumentOrShadowRoot/elementFromPoint": {
"modified": "2019-03-23T23:19:33.886Z",
"contributors": [
diff --git a/files/zh-cn/learn/javascript/asynchronous/choosing_the_right_approach/index.html b/files/zh-cn/conflicting/learn/javascript/asynchronous/index.html
index 4241740479..278746ae22 100644
--- a/files/zh-cn/learn/javascript/asynchronous/choosing_the_right_approach/index.html
+++ b/files/zh-cn/conflicting/learn/javascript/asynchronous/index.html
@@ -1,8 +1,8 @@
---
title: 选择正确的方法
-slug: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
+slug: conflicting/Learn/JavaScript/Asynchronous
translation_of: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
-original_slug: learn/JavaScript/异步/Choosing_the_right_approach
+original_slug: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
---
<div>{{LearnSidebar}}</div>
diff --git a/files/zh-cn/learn/javascript/asynchronous/concepts/index.html b/files/zh-cn/conflicting/learn/javascript/asynchronous/introducing/index.html
index 757eee777c..291cf15837 100644
--- a/files/zh-cn/learn/javascript/asynchronous/concepts/index.html
+++ b/files/zh-cn/conflicting/learn/javascript/asynchronous/introducing/index.html
@@ -1,6 +1,6 @@
---
title: 通用异步编程概念
-slug: Learn/JavaScript/Asynchronous/Concepts
+slug: conflicting/Learn/JavaScript/Asynchronous/Introducing
tags:
- JavaScript
- Promises
@@ -9,7 +9,7 @@ tags:
- 异步
- 阻塞
translation_of: Learn/JavaScript/Asynchronous/Concepts
-original_slug: learn/JavaScript/异步/概念
+original_slug: Learn/JavaScript/Asynchronous/Concepts
---
<div>{{LearnSidebar}}{{NextMenu("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous")}}</div>
diff --git a/files/zh-cn/learn/javascript/asynchronous/async_await/index.html b/files/zh-cn/conflicting/learn/javascript/asynchronous/promises/index.html
index d584914106..3c73fecd3d 100644
--- a/files/zh-cn/learn/javascript/asynchronous/async_await/index.html
+++ b/files/zh-cn/conflicting/learn/javascript/asynchronous/promises/index.html
@@ -1,8 +1,8 @@
---
title: async和await:让异步编程更简单
-slug: Learn/JavaScript/Asynchronous/Async_await
+slug: conflicting/Learn/JavaScript/Asynchronous/Promises
translation_of: Learn/JavaScript/Asynchronous/Async_await
-original_slug: learn/JavaScript/异步/Async_await
+original_slug: Learn/JavaScript/Asynchronous/Async_await
---
<div>{{LearnSidebar}}</div>
diff --git a/files/zh-cn/learn/javascript/asynchronous/timeouts_and_intervals/index.html b/files/zh-cn/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.html
index 0819a5aff0..a3500922af 100644
--- a/files/zh-cn/learn/javascript/asynchronous/timeouts_and_intervals/index.html
+++ b/files/zh-cn/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.html
@@ -1,8 +1,8 @@
---
title: '合作异步JavaScript: 超时和间隔'
-slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+slug: conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df
translation_of: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
-original_slug: learn/JavaScript/异步/超时和间隔
+original_slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
---
<div>{{LearnSidebar}}</div>
diff --git a/files/zh-cn/web/api/document/onvisibilitychange/index.html b/files/zh-cn/conflicting/web/api/document/visibilitychange_event/index.html
index 22fb0e4db4..e79fcf4cf9 100644
--- a/files/zh-cn/web/api/document/onvisibilitychange/index.html
+++ b/files/zh-cn/conflicting/web/api/document/visibilitychange_event/index.html
@@ -1,7 +1,8 @@
---
title: Document.onvisibilitychange
-slug: Web/API/Document/onvisibilitychange
+slug: conflicting/Web/API/Document/visibilitychange_event
translation_of: Web/API/Document/onvisibilitychange
+original_slug: Web/API/Document/onvisibilitychange
---
<div>{{ApiRef('DOM')}}</div>
diff --git a/files/zh-cn/web/api/performance/onresourcetimingbufferfull/index.html b/files/zh-cn/web/api/performance/resourcetimingbufferfull_event/index.html
index 7e26cf4793..0b5890b069 100644
--- a/files/zh-cn/web/api/performance/onresourcetimingbufferfull/index.html
+++ b/files/zh-cn/web/api/performance/resourcetimingbufferfull_event/index.html
@@ -1,7 +1,8 @@
---
title: Performance.onresourcetimingbufferfull
-slug: Web/API/Performance/onresourcetimingbufferfull
+slug: Web/API/Performance/resourcetimingbufferfull_event
translation_of: Web/API/Performance/onresourcetimingbufferfull
+original_slug: Web/API/Performance/onresourcetimingbufferfull
---
<div>{{APIRef("Resource Timing API")}}</div>
diff --git a/files/zh-cn/web/api/window/onappinstalled/index.html b/files/zh-cn/web/api/window/appinstalled_event/index.html
index 21662ca3f6..f5f098c903 100644
--- a/files/zh-cn/web/api/window/onappinstalled/index.html
+++ b/files/zh-cn/web/api/window/appinstalled_event/index.html
@@ -1,7 +1,8 @@
---
title: Window.onappinstalled
-slug: Web/API/Window/onappinstalled
+slug: Web/API/Window/appinstalled_event
translation_of: Web/API/Window/onappinstalled
+original_slug: Web/API/Window/onappinstalled
---
<div>{{APIRef}}</div>
diff --git a/files/zh-tw/_redirects.txt b/files/zh-tw/_redirects.txt
index f7508b3a88..8a72d2b9d9 100644
--- a/files/zh-tw/_redirects.txt
+++ b/files/zh-tw/_redirects.txt
@@ -428,6 +428,10 @@
/zh-TW/docs/Learn/HTML/Multimedia_and_embedding/其他_嵌入_技術 /zh-TW/docs/Learn/HTML/Multimedia_and_embedding/Other_embedding_technologies
/zh-TW/docs/Learn/HTML/Tables/基礎 /zh-TW/docs/Learn/HTML/Tables/Basics
/zh-TW/docs/Learn/How_to_contribute /zh-TW/docs/orphaned/Learn/How_to_contribute
+/zh-TW/docs/Learn/JavaScript/Asynchronous/Async_await /zh-TW/docs/conflicting/Learn/JavaScript/Asynchronous/Promises
+/zh-TW/docs/Learn/JavaScript/Asynchronous/Choosing_the_right_approach /zh-TW/docs/conflicting/Learn/JavaScript/Asynchronous
+/zh-TW/docs/Learn/JavaScript/Asynchronous/Concepts /zh-TW/docs/conflicting/Learn/JavaScript/Asynchronous/Introducing
+/zh-TW/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals /zh-TW/docs/conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df
/zh-TW/docs/Learn/JavaScript/Building_blocks/函數 /zh-TW/docs/Learn/JavaScript/Building_blocks/Functions
/zh-TW/docs/Learn/JavaScript/Building_blocks/回傳值 /zh-TW/docs/Learn/JavaScript/Building_blocks/Return_values
/zh-TW/docs/Learn/JavaScript/Building_blocks/建立自己的功能函數 /zh-TW/docs/Learn/JavaScript/Building_blocks/Build_your_own_function
diff --git a/files/zh-tw/learn/javascript/asynchronous/choosing_the_right_approach/index.html b/files/zh-tw/conflicting/learn/javascript/asynchronous/index.html
index 6099d470fa..de99e1aed8 100644
--- a/files/zh-tw/learn/javascript/asynchronous/choosing_the_right_approach/index.html
+++ b/files/zh-tw/conflicting/learn/javascript/asynchronous/index.html
@@ -1,6 +1,6 @@
---
title: 選擇正確的方法
-slug: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
+slug: conflicting/Learn/JavaScript/Asynchronous
tags:
- Beginner
- Intervals
@@ -15,6 +15,7 @@ tags:
- setInterval
- setTimeout
- timeouts
+original_slug: Learn/JavaScript/Asynchronous/Choosing_the_right_approach
---
<div>{{LearnSidebar}}</div>
diff --git a/files/zh-tw/learn/javascript/asynchronous/concepts/index.html b/files/zh-tw/conflicting/learn/javascript/asynchronous/introducing/index.html
index 0db2f89275..5cddfa32cb 100644
--- a/files/zh-tw/learn/javascript/asynchronous/concepts/index.html
+++ b/files/zh-tw/conflicting/learn/javascript/asynchronous/introducing/index.html
@@ -1,6 +1,6 @@
---
title: 非同步程式設計通用概念
-slug: Learn/JavaScript/Asynchronous/Concepts
+slug: conflicting/Learn/JavaScript/Asynchronous/Introducing
tags:
- JavaScript
- Learn
@@ -10,6 +10,7 @@ tags:
- blocking
- 非同步
- 執行緒
+original_slug: Learn/JavaScript/Asynchronous/Concepts
---
<div>{{LearnSidebar}}{{NextMenu("Learn/JavaScript/Asynchronous/Introducing", "Learn/JavaScript/Asynchronous")}}</div>
diff --git a/files/zh-tw/learn/javascript/asynchronous/async_await/index.html b/files/zh-tw/conflicting/learn/javascript/asynchronous/promises/index.html
index 3c594daf2a..911ba3caba 100644
--- a/files/zh-tw/learn/javascript/asynchronous/async_await/index.html
+++ b/files/zh-tw/conflicting/learn/javascript/asynchronous/promises/index.html
@@ -1,6 +1,6 @@
---
title: 利用 async 及 await 讓非同步程式設計變得更容易
-slug: Learn/JavaScript/Asynchronous/Async_await
+slug: conflicting/Learn/JavaScript/Asynchronous/Promises
tags:
- Beginner
- CodingScripting
@@ -11,6 +11,7 @@ tags:
- async
- asynchronous
- await
+original_slug: Learn/JavaScript/Asynchronous/Async_await
---
<div>{{LearnSidebar}}</div>
diff --git a/files/zh-tw/learn/javascript/asynchronous/timeouts_and_intervals/index.html b/files/zh-tw/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.html
index 9e076bcad4..7d0a0d7313 100644
--- a/files/zh-tw/learn/javascript/asynchronous/timeouts_and_intervals/index.html
+++ b/files/zh-tw/conflicting/learn/javascript/asynchronous_ae5a561b0ec11fc53c167201aa8af5df/index.html
@@ -1,6 +1,6 @@
---
title: '協同的非同步 JavaScript: Timeouts 和 intervals'
-slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
+slug: conflicting/Learn/JavaScript/Asynchronous_ae5a561b0ec11fc53c167201aa8af5df
tags:
- Animation
- Beginner
@@ -14,6 +14,7 @@ tags:
- setInterval
- setTimeout
- timeouts
+original_slug: Learn/JavaScript/Asynchronous/Timeouts_and_intervals
---
<div>{{LearnSidebar}}</div>
@@ -533,7 +534,7 @@ const result = document.querySelector('.result');</pre>
rotateCount = (timestamp - startTime) / 3;
rotateCount %= 360;
-
+
spinner.style.transform = 'rotate(' + rotateCount + 'deg)';
rAF = requestAnimationFrame(draw);
}</pre>