UNPKG

@surveycake/utils

Version:

SurveyCake Javascript Utils

29 lines (28 loc) 680 B
/** * @module decorator */ /** * Add throttle to a function. * * @typeparam T type or interface of origin function. * @param time debounce time. * @returns The behavior is the same as origin function, but with throttle. * * ```ts * const origin = () => ...; * const result = throttle(250)(origin); * ``` * * ```ts * class Greeter { * greeting: string; * constructor(message: string) { * this.greeting = message; * } * * @throttle(500) * greet = () => `Hello, ${this.greeting}`; * } * ``` */ export declare function throttle<T extends (...args: any[]) => void>(time: number): (fn: T) => (...args: Parameters<T>) => void;