We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0304586 commit 5920a48Copy full SHA for 5920a48
throttle.js
@@ -0,0 +1,14 @@
1
+/*
2
+ the handler would be invoked atmost once in `limit` seconds
3
+ examples: infinite scrolling check for the bottom of the screen etc...
4
+*/
5
+const throttle = (handler, limit) => {
6
+ let inThrottle = false;
7
+ return function () {
8
+ if (!inThrottle) {
9
+ handler.apply(this, arguments);
10
+ inThrottle = true;
11
+ setTimeout(() => inThrottle = false, limit);
12
+ }
13
14
+}
0 commit comments