From c4f5870b057ff18c129699f8d26845909cce6f11 Mon Sep 17 00:00:00 2001 From: ichiyouda <95156295+ichiyouda@users.noreply.github.com> Date: Tue, 27 Jun 2023 10:41:46 +0800 Subject: [PATCH 1/5] Update solution.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3. …… if we had ignored calls, 感觉这句译为「如果我们有被忽略的调用」,读起来更好理解一些,希望不是错译。 --- .../09-call-apply-decorators/04-throttle/solution.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md b/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md index 7d747cc452..2655b59829 100644 --- a/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md +++ b/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md @@ -32,7 +32,7 @@ function throttle(func, ms) { 调用 `throttle(func, ms)` 返回 `wrapper`。 1. 在第一次调用期间,`wrapper` 只运行 `func` 并设置冷却状态(`isThrottled = true`)。 -2. 在这种状态下,所有调用都记忆在 `savedArgs/savedThis` 中。请注意,上下文和参数(arguments)同等重要,应该被记下来。我们同时需要他们以重现调用。 -3. ……然后经过 `ms` 毫秒后,触发 `setTimeout`。冷却状态被移除(`isThrottled = false`),如果我们忽略了调用,则将使用最后记忆的参数和上下文执行 `wrapper`。 +2. 在冷却状态下,所有调用都被保存在 `savedArgs/savedThis` 中。请注意,上下文(this)和参数(arguments)都很重要,应该被保存下来。我们同时需要它们来重现调用。 +3. 经过 `ms` 毫秒后,`setTimeout`中的函数被触发。冷却状态被移除(`isThrottled = false`),如果我们有被忽略(return)的调用,将使用最后保存的参数和上下文运行 `wrapper`。 -第 3 步运行的不是 `func`,而是 `wrapper`,因为我们不仅需要执行 `func`,还需要再次进入冷却状态并设置 timeout 以重置它。 +第 3 步运行的不是 `func`,而是 `wrapper`,因为我们不仅需要执行 `func`,还需要再次进入冷却状态并设置延时以重置节流。 From e26be4f9e47aeb26270f98208d1727b02cf8fad1 Mon Sep 17 00:00:00 2001 From: ichiyouda <95156295+ichiyouda@users.noreply.github.com> Date: Wed, 28 Jun 2023 09:00:05 +0800 Subject: [PATCH 2/5] Update solution.md minor changes for better reading. --- .../09-call-apply-decorators/04-throttle/solution.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md b/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md index 2655b59829..1314f94123 100644 --- a/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md +++ b/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md @@ -32,7 +32,7 @@ function throttle(func, ms) { 调用 `throttle(func, ms)` 返回 `wrapper`。 1. 在第一次调用期间,`wrapper` 只运行 `func` 并设置冷却状态(`isThrottled = true`)。 -2. 在冷却状态下,所有调用都被保存在 `savedArgs/savedThis` 中。请注意,上下文(this)和参数(arguments)都很重要,应该被保存下来。我们同时需要它们来重现调用。 -3. 经过 `ms` 毫秒后,`setTimeout`中的函数被触发。冷却状态被移除(`isThrottled = false`),如果我们有被忽略(return)的调用,将使用最后保存的参数和上下文运行 `wrapper`。 +2. 在冷却状态下,所有调用都被保存在 `savedArgs/savedThis` 中。请注意,上下文(this)和参数(arguments)都很重要,应该被保存下来。我们需要它们来重现调用。 +3. 经过 `ms` 毫秒后,`setTimeout`中的函数被触发。冷却状态被移除(`isThrottled = false`),如果存在被忽略的调用,将使用最后保存的参数和上下文运行 `wrapper`。 -第 3 步运行的不是 `func`,而是 `wrapper`,因为我们不仅需要执行 `func`,还需要再次进入冷却状态并设置延时以重置节流。 +第 3 步运行的不是 `func`,而是 `wrapper`,因为我们不仅需要运行 `func`,还需要再次进入冷却状态并设置`setTimeout`以重置节流。 From 3ea944c17836683d3d850b515ba900a3c08920f8 Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 2 Jul 2023 19:46:46 +0800 Subject: [PATCH 3/5] feat: 1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md From 0d2bd74aa28208c01bac51449332d9499f1e525d Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 2 Jul 2023 19:49:10 +0800 Subject: [PATCH 4/5] feat: update 1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md --- .../09-call-apply-decorators/04-throttle/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md b/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md index 1314f94123..af285aca40 100644 --- a/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md +++ b/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md @@ -33,6 +33,6 @@ function throttle(func, ms) { 1. 在第一次调用期间,`wrapper` 只运行 `func` 并设置冷却状态(`isThrottled = true`)。 2. 在冷却状态下,所有调用都被保存在 `savedArgs/savedThis` 中。请注意,上下文(this)和参数(arguments)都很重要,应该被保存下来。我们需要它们来重现调用。 -3. 经过 `ms` 毫秒后,`setTimeout`中的函数被触发。冷却状态被移除(`isThrottled = false`),如果存在被忽略的调用,将使用最后保存的参数和上下文运行 `wrapper`。 +3. 经过 `ms` 毫秒后,`setTimeout`中的函数被触发。冷却状态被移除(`isThrottled = false`),如果存在被忽略的调用,将使用最后一次调用保存的参数和上下文运行 `wrapper`。 第 3 步运行的不是 `func`,而是 `wrapper`,因为我们不仅需要运行 `func`,还需要再次进入冷却状态并设置`setTimeout`以重置节流。 From 8c0d8568bc579df4e0201da292f7092cd9e2dcdb Mon Sep 17 00:00:00 2001 From: LeviDing Date: Sun, 2 Jul 2023 19:49:21 +0800 Subject: [PATCH 5/5] feat: update 1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md --- .../09-call-apply-decorators/04-throttle/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md b/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md index af285aca40..6ed9ccf703 100644 --- a/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md +++ b/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md @@ -35,4 +35,4 @@ function throttle(func, ms) { 2. 在冷却状态下,所有调用都被保存在 `savedArgs/savedThis` 中。请注意,上下文(this)和参数(arguments)都很重要,应该被保存下来。我们需要它们来重现调用。 3. 经过 `ms` 毫秒后,`setTimeout`中的函数被触发。冷却状态被移除(`isThrottled = false`),如果存在被忽略的调用,将使用最后一次调用保存的参数和上下文运行 `wrapper`。 -第 3 步运行的不是 `func`,而是 `wrapper`,因为我们不仅需要运行 `func`,还需要再次进入冷却状态并设置`setTimeout`以重置节流。 +第 3 步运行的不是 `func`,而是 `wrapper`,因为我们不仅需要执行 `func`,还需要再次进入冷却状态并设置 `setTimeout` 以重置节流。