UNPKG

tamda

Version:

Practical functional programming library for TypeScript

18 lines (17 loc) 616 B
/** * Creates a function that debounces function `fn` so that it is only invoked * when `time` in milliseconds has passed without any calls to the generated function. * @note Calling the generated function will reset the timer. * @param fn Function to invoke. * @param time Amount of milliseconds to debounce. Default: `0` * @example * let count = 0; * const debounced = debounce(() => count++); * debounced(); * debounced(); * console.log(count); * // 0 * setTimeout(() => console.log(count)); * // 1 */ export declare function debounce<F extends Function>(fn: F, time?: number): F;