Skip to content

Commit

Permalink
Fix debounce for ssr (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashanau authored Nov 16, 2023
1 parent 95c897c commit ff90df1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const noop = () => {}; // eslint-disable-line @typescript-eslint/no-empty
export function throttle<T extends any[]>(
fn: (...args: T) => unknown,
threshold = 50,
scope = window,
scope = typeof window !== 'undefined' ? window : undefined,
) {
let prevDate: number = Date.now() - threshold;
let timeoutId: ReturnType<typeof setTimeout>;
Expand Down Expand Up @@ -34,7 +34,7 @@ export function throttle<T extends any[]>(
export function debounce<T extends any[]>(
fn: (...args: T) => unknown,
delay: number,
context = window,
context = typeof window !== 'undefined' ? window : undefined,
) {
let timeoutId: ReturnType<typeof setTimeout>;
let args: T;
Expand Down

0 comments on commit ff90df1

Please sign in to comment.