UNPKG

@graphique/graphique

Version:

A data visualization system for React based on the Grammar of Graphics.

13 lines (12 loc) 303 B
export const debounce = (delay: number, fn: (...args: any[]) => void) => { let timerId: ReturnType<typeof setTimeout> | null return (...args: any[]) => { if (timerId) { clearTimeout(timerId) } timerId = setTimeout(() => { fn(...args) timerId = null }, delay) } }