Skip to content

Commit

Permalink
fix: clean up typing
Browse files Browse the repository at this point in the history
  • Loading branch information
martinstark committed Apr 29, 2021
1 parent 8b9698c commit 9119857
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export const throttle = <T extends (...args: any[]) => any>(
fn: T,
export const throttle = <R, A extends any[]>(
fn: (...args: A) => R,
delay: number
): [T | (() => void), () => void] => {
): [(...args: A) => R | undefined, () => void] => {
let wait = false;
let timeout: undefined | number;
let cancelled = false;

return [
(...args: any[]) => {
(...args: A) => {
if (cancelled) return undefined;
if (wait) return undefined;

Expand Down

0 comments on commit 9119857

Please sign in to comment.