Skip to content

Commit fc9cc3e

Browse files
ichiyoudaleviding
andauthored
feat: 语句优化 1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md (#1161)
* Update solution.md 3. …… if we had ignored calls, 感觉这句译为「如果我们有被忽略的调用」,读起来更好理解一些,希望不是错译。 * Update solution.md minor changes for better reading. * feat: 1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md * feat: update 1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md * feat: update 1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md --------- Co-authored-by: LeviDing <imdingxuewen@gmail.com>
1 parent e37a1fe commit fc9cc3e

File tree

1 file changed

+3
-3
lines changed
  • 1-js/06-advanced-functions/09-call-apply-decorators/04-throttle

1 file changed

+3
-3
lines changed

1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function throttle(func, ms) {
3232
调用 `throttle(func, ms)` 返回 `wrapper`
3333

3434
1. 在第一次调用期间,`wrapper` 只运行 `func` 并设置冷却状态(`isThrottled = true`)。
35-
2. 在这种状态下,所有调用都记忆在 `savedArgs/savedThis` 中。请注意,上下文和参数(arguments)同等重要,应该被记下来。我们同时需要他们以重现调用
36-
3. ……然后经过 `ms` 毫秒后,触发 `setTimeout`。冷却状态被移除(`isThrottled = false`),如果我们忽略了调用,则将使用最后记忆的参数和上下文执行 `wrapper`
35+
2. 在冷却状态下,所有调用都被保存在 `savedArgs/savedThis` 中。请注意,上下文(this)和参数(arguments)都很重要,应该被保存下来。我们需要它们来重现调用
36+
3. 经过 `ms` 毫秒后,`setTimeout`中的函数被触发。冷却状态被移除(`isThrottled = false`),如果存在被忽略的调用,将使用最后一次调用保存的参数和上下文运行 `wrapper`
3737

38-
第 3 步运行的不是 `func`,而是 `wrapper`,因为我们不仅需要执行 `func`,还需要再次进入冷却状态并设置 timeout 以重置它
38+
第 3 步运行的不是 `func`,而是 `wrapper`,因为我们不仅需要执行 `func`,还需要再次进入冷却状态并设置 `setTimeout` 以重置节流

0 commit comments

Comments
 (0)