MCPcopy
hub / github.com/2factorauth/twofactorauth / debounce

Function debounce

js/search.js:75–89  ·  view source on GitHub ↗

* Returns a function, that, as long as it continues to be invoked, will not * be triggered. The function will be called after it stops being called for * N milliseconds. * * @param func The function to be debounced * @param wait The time in ms to debounce

(func, wait)

Source from the content-addressed store, hash-verified

73 * @param wait The time in ms to debounce
74 */
75function debounce(func, wait) {
76 var timeout;
77
78 return function() {
79 var context = this, args = arguments;
80 var later = function() {
81 timeout = null;
82 func.apply(context, args);
83 };
84
85 clearTimeout(timeout);
86 timeout = setTimeout(later, wait);
87 if (!timeout) func.apply(context, args);
88 };
89};

Callers 1

search.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected