From 6af2117228bc426ed4468dd0c5cd7ff469719d08 Mon Sep 17 00:00:00 2001 From: Prasit Tongpradit Date: Sun, 5 Apr 2026 20:13:32 +0700 Subject: [PATCH] docs: translate async section (8 articles) --- 1-js/11-async/01-callbacks/article.md | 147 +++++----- .../01-re-resolve/solution.md | 4 +- .../02-promise-basics/01-re-resolve/task.md | 2 +- .../02-delay-promise/solution.md | 4 +- .../02-delay-promise/task.md | 10 +- .../solution.view/index.html | 2 +- .../03-animate-circle-promise/task.md | 8 +- 1-js/11-async/02-promise-basics/article.md | 255 +++++++++--------- .../01-then-vs-catch/solution.md | 10 +- .../01-then-vs-catch/task.md | 6 +- 1-js/11-async/03-promise-chaining/article.md | 170 ++++++------ .../03-promise-chaining/getMessage.js | 2 +- 1-js/11-async/03-promise-chaining/head.html | 2 +- .../01-error-async/solution.md | 6 +- .../01-error-async/task.md | 4 +- .../04-promise-error-handling/article.md | 114 ++++---- 1-js/11-async/05-promise-api/article.md | 150 +++++------ 1-js/11-async/06-promisify/article.md | 73 +++-- 1-js/11-async/07-microtask-queue/article.md | 78 +++--- .../01-rewrite-async/solution.md | 14 +- .../08-async-await/01-rewrite-async/task.md | 4 +- .../02-rewrite-async-2/solution.md | 18 +- .../08-async-await/02-rewrite-async-2/task.md | 14 +- .../03-async-from-regular/solution.md | 7 +- .../03-async-from-regular/task.md | 12 +- .../04-promise-all-failure/solution.md | 48 ++-- .../04-promise-all-failure/task.md | 36 +-- 1-js/11-async/08-async-await/article.md | 135 +++++----- 28 files changed, 676 insertions(+), 659 deletions(-) diff --git a/1-js/11-async/01-callbacks/article.md b/1-js/11-async/01-callbacks/article.md index 57115a909..bab5811a9 100644 --- a/1-js/11-async/01-callbacks/article.md +++ b/1-js/11-async/01-callbacks/article.md @@ -1,68 +1,67 @@ +# บทนำ: callback -# Introduction: callbacks +```warn header="ตัวอย่างในบทนี้ใช้ browser methods" +เพื่ออธิบาย callback, promise และ concept ที่เกี่ยวข้อง เราจะหยิบ browser methods มาใช้ โดยเฉพาะการโหลด script และจัดการ document เบื้องต้น -```warn header="We use browser methods in examples here" -To demonstrate the use of callbacks, promises and other abstract concepts, we'll be using some browser methods: specifically, loading scripts and performing simple document manipulations. +ถ้ายังไม่คุ้นเคยกับพวกนี้และอ่านแล้วงง ลองข้ามไปอ่าน [ส่วนถัดไป](/document) ของ tutorial ก่อนก็ได้ -If you're not familiar with these methods, and their usage in the examples is confusing, you may want to read a few chapters from the [next part](/document) of the tutorial. - -Although, we'll try to make things clear anyway. There won't be anything really complex browser-wise. +แต่เราจะพยายามอธิบายให้ชัดอยู่ดี — ไม่มีอะไรที่ซับซ้อนมากในแง่ browser ``` -Many functions are provided by JavaScript host environments that allow you to schedule *asynchronous* actions. In other words, actions that we initiate now, but they finish later. +JavaScript host environment มีฟังก์ชันหลายตัวที่ช่วยให้เรา schedule งาน *asynchronous* ได้ — พูดง่ายๆ คือ "สั่งให้ทำ แต่ไม่ต้องรอ ทำเสร็จแล้วค่อยบอก" -For instance, one such function is the `setTimeout` function. +ตัวอย่างที่คุ้นกันดีที่สุดคือ `setTimeout` -There are other real-world examples of asynchronous actions, e.g. loading scripts and modules (we'll cover them in later chapters). +งาน asynchronous ในชีวิตจริงยังมีอีก เช่น การโหลด script หรือ module (จะพูดถึงในบทหลัง) -Take a look at the function `loadScript(src)`, that loads a script with the given `src`: +ลองดูฟังก์ชัน `loadScript(src)` ที่โหลด script จาก `src` ที่กำหนด: ```js function loadScript(src) { - // creates a