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 e4e8bd2 commit f880cd7Copy full SHA for f880cd7
README.md
@@ -2544,4 +2544,6 @@ https://leetcode.cn/problems/design-cancellable-function/
2544
2545
https://leetcode.cn/problems/group-by
2546
2547
+https://leetcode.cn/problems/debounce
2548
+
2549
</details>
debounce/index.ts
@@ -0,0 +1,15 @@
1
+type F = (...p: any[]) => any;
2
3
+function debounce(fn: F, t: number): F {
4
+ let timer: number | undefined;
5
+ return function (...args) {
6
+ clearTimeout(timer);
7
8
+ timer = setTimeout(() => {
9
+ fn(...args);
10
+ }, t);
11
+ };
12
+}
13
+export default debounce;
14
15
+export type { F };
0 commit comments