From 239abf4eca2438e92fb6b2c16c5c31fc83db6d28 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 5 Feb 2016 09:51:09 +0000 Subject: [PATCH] Style things from PR comments --- src/ratelimitedfunc.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ratelimitedfunc.js b/src/ratelimitedfunc.js index f7cf165414..453669b477 100644 --- a/src/ratelimitedfunc.js +++ b/src/ratelimitedfunc.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -module.exports = function(f, min_interval_ms) { +module.exports = function(f, minIntervalMs) { this.lastCall = 0; this.scheduledCall = undefined; @@ -22,16 +22,17 @@ module.exports = function(f, min_interval_ms) { return function() { var now = Date.now(); - if (self.lastCall < now - min_interval_ms) { + if (self.lastCall < now - minIntervalMs) { f.apply(this); self.lastCall = now; } else if (self.scheduledCall === undefined) { - self.scheduledCall = setTimeout(() => { + self.scheduledCall = setTimeout( + () => { self.scheduledCall = undefined; f.apply(this); self.lastCall = now; }, - (self.lastCall + min_interval_ms) - now + (self.lastCall + minIntervalMs) - now ); } };