Skip to content

Commit 1ac86b6

Browse files
committed
Type inference for the throttle function
1 parent 72c3571 commit 1ac86b6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

apps/webapp/app/utils/throttle.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//From: https://kettanaito.com/blog/debounce-vs-throttle
22

33
/** A very simple throttle. Will execute the function at the end of each period and discard any other calls during that period. */
4-
export function throttle(
5-
func: (...args: any[]) => void,
4+
export function throttle<TArgs extends unknown[]>(
5+
func: (...args: TArgs) => void,
66
durationMs: number
7-
): (...args: any[]) => void {
7+
): (...args: TArgs) => void {
88
let isPrimedToFire = false;
99

10-
return (...args: any[]) => {
10+
return (...args: TArgs) => {
1111
if (!isPrimedToFire) {
1212
isPrimedToFire = true;
1313

0 commit comments

Comments
 (0)