Last active
October 25, 2018 14:06
-
-
Save malithmcr/055bcc354f8cca799d65d6e042a87249 to your computer and use it in GitHub Desktop.
Revisions
-
malithmcr revised this gist
Oct 25, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,4 +13,4 @@ function throttle(fn, wait) { time = Date.now(); } } } -
malithmcr created this gist
Oct 25, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ /** * throttle * @param {fn} callback func * @param {wait} number - wait time * @public */ function throttle(fn, wait) { var time = Date.now(); return function() { if ((time + wait - Date.now()) < 0) { fn(); time = Date.now(); } } }: