UNPKG

@sapphire/utilities

Version:
17 lines (15 loc) 614 B
type ThrottleFn<T extends (...args: any[]) => any> = T & { flush: () => void; }; /** * Creates a throttled function that only invokes `func` at most once per * every `wait` milliseconds. The throttled function comes with a `flush` method to * reset the last time the throttled function was invoked. * * @param func The function to throttle. * @param wait The number of milliseconds to throttle invocations to. * * @returns Returns the new throttled function. */ declare function throttle<T extends (...args: any[]) => any>(func: T, wait: number): ThrottleFn<T>; export { type ThrottleFn, throttle };