UNPKG

typedash

Version:

modern, type-safe collection of utility functions

25 lines (22 loc) 1.06 kB
import { A as AnyFunction } from '../AnyFunction-DuIh5Fcc.js'; /** * Creates a debounced function that delays invoking `func` until after `delay` milliseconds have elapsed since the last time the debounced function was invoked. * @param func The function to debounce. * @param delay The number of milliseconds to delay. * @param options Optional configuration options. * @param options.leading Whether to call the function on the leading edge of the timeout. * @returns A debounced function that can be called multiple times, but only invokes `func` once per `delay` milliseconds. */ declare function debounce<TFunction extends AnyFunction<void | undefined>>(func: TFunction, delay: number, options?: { /** * Whether to call the function on the leading edge of the timeout. * @default false */ leading?: boolean; }): DebouncedFunction<TFunction>; interface DebouncedFunction<TFunction extends AnyFunction<void | undefined>> { (...args: Parameters<TFunction>): void; clear(): void; flush(): void; } export { debounce };