UNPKG

@surveycake/utils

Version:

SurveyCake Javascript Utils

29 lines (28 loc) 675 B
/** * @module decorator */ /** * Add exhaust 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 exhaust. * * ```ts * const origin = () => ...; * const result = exhaust(250)(origin); * ``` * * ```ts * class Greeter { * greeting: string; * constructor(message: string) { * this.greeting = message; * } * * @exhaust(500) * greet = () => `Hello, ${this.greeting}`; * } * ``` */ export declare function exhaust<T extends (...args: any[]) => void>(time: number): (fn: T) => (...args: Parameters<T>) => void;