Skip to content

Commit fba4ee2

Browse files
committed
feat: update translation
1 parent 20f1775 commit fba4ee2

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

5-network/03-fetch-progress/article.md

+2
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,5 @@ alert(commits[0].author.login);
110110
最后,我们得到了结果(以字符串或 blob 的形式表示,什么方便就用什么),并在过程中对进度进行了跟踪。
111111

112112
再强调一遍,这不能用于 **上传** 过程(现在无法通过 `fetch` 获取),仅用于 **下载** 过程。
113+
114+
另外,如果大小未知,我们应该检查循环中的 `receivedLength`,一旦达到一定的限制就将其中断。这样 `chunks` 就不会溢出内存了。

5-network/04-fetch-abort/article.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ alert(signal.aborted); // true
4848

4949
正如我们所看到的,`AbortController` 只是在 `abort()` 被调用时传递 `abort` 事件的一种方式。
5050

51-
我们可以自己在代码中实现相同类型的事件监听,而根本不需要 `AbortController` 对象。
51+
我们可以自己在代码中实现相同类型的事件监听,而不需要 `AbortController` 对象。
5252

53-
但是有价值的是,`fetch` 知道如何与 `AbortController` 对象一起工作,它们俩是集成在一起的
53+
但是有价值的是,`fetch` 知道如何与 `AbortController` 对象一起工作。它们是集成在一起的
5454

5555
## 与 fetch 一起使用
5656

@@ -97,7 +97,7 @@ try {
9797

9898
## AbortController 是可伸缩的
9999

100-
`AbortController` 是可伸缩的它允许一次取消多个 fetch。
100+
`AbortController` 是可伸缩的它允许一次取消多个 fetch。
101101

102102
这是一个代码草稿,该代码并行 fetch 很多 `urls`,并使用单个控制器将其全部中止:
103103

@@ -113,8 +113,8 @@ let fetchJobs = urls.map(url => fetch(url, {
113113

114114
let results = await Promise.all(fetchJobs);
115115

116-
// 如果 controller.abort() 被从其他地方调用
117-
// 它将中止所有 fetch
116+
// controller.abort() 被从任何地方调用
117+
// 它都将中止所有 fetch
118118
```
119119

120120
如果我们有自己的与 `fetch` 不同的异步任务,我们可以使用单个 `AbortController` 中止这些任务以及 fetch。
@@ -137,8 +137,8 @@ let fetchJobs = urls.map(url => fetch(url, { // fetches
137137
// 等待完成我们的任务和所有 fetch
138138
let results = await Promise.all([...fetchJobs, ourJob]);
139139

140-
// 如果 controller.abort() 被从其他地方调用
141-
// 它将中止所有 fetch 和 ourJob
140+
// controller.abort() 被从任何地方调用
141+
// 它都将中止所有 fetch 和 ourJob
142142
```
143143

144144
## 总结

0 commit comments

Comments
 (0)