aboutsummaryrefslogtreecommitdiff
path: root/src/utils/debounce.ts
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-11-25 19:25:35 +0100
committerVendicated <vendicated@riseup.net>2022-11-25 19:25:35 +0100
commita85ec594a77557e5f48c4cf1aa33680e0da94654 (patch)
treee88fa38f588fef187a0caec884763fc50da8385d /src/utils/debounce.ts
parentc2c6c9fccb3b94340037d2136d647817d0a1c916 (diff)
downloadVencord-a85ec594a77557e5f48c4cf1aa33680e0da94654.tar.gz
Vencord-a85ec594a77557e5f48c4cf1aa33680e0da94654.tar.bz2
Vencord-a85ec594a77557e5f48c4cf1aa33680e0da94654.zip
[skip ci] docs docs docs
Diffstat (limited to 'src/utils/debounce.ts')
-rw-r--r--src/utils/debounce.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/utils/debounce.ts b/src/utils/debounce.ts
index d9e19de..6e5bba6 100644
--- a/src/utils/debounce.ts
+++ b/src/utils/debounce.ts
@@ -16,6 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+/**
+ * Returns a new function that will call the wrapped function
+ * after the specified delay. If the function is called again
+ * within the delay, the timer will be reset.
+ * @param func The function to wrap
+ * @param delay The delay in milliseconds
+ */
export function debounce<T extends Function>(func: T, delay = 300): T {
let timeout: NodeJS.Timeout;
return function (...args: any[]) {