From 03822f7b54b503dba19fed563f19501bc3706978 Mon Sep 17 00:00:00 2001 From: Taly Date: Wed, 20 Jul 2022 11:22:40 +0300 Subject: [PATCH] Update decorators.js --- src/frontend/js/utils/decorators.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/frontend/js/utils/decorators.js b/src/frontend/js/utils/decorators.js index fe47698..4e37fe6 100644 --- a/src/frontend/js/utils/decorators.js +++ b/src/frontend/js/utils/decorators.js @@ -3,11 +3,12 @@ */ export class Decorators { /** + * Throttle decorator function * + * @param {Function} func - function to throttle + * @param {number} ms - milliseconds to throttle * - * @param func - * @param ms - * @return {wrapper} + * @returns {wrapper} */ static throttle(func, ms) { let isThrottled = false, @@ -15,18 +16,18 @@ export class Decorators { savedThis; function wrapper() { - if (isThrottled) { // (2) + if (isThrottled) { savedArgs = arguments; savedThis = this; return; } - func.apply(this, arguments); // (1) + func.apply(this, arguments); isThrottled = true; setTimeout(function() { - isThrottled = false; // (3) + isThrottled = false; if (savedArgs) { wrapper.apply(savedThis, savedArgs);