UNPKG

@resk/core

Version:

An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla

53 lines (52 loc) 1.94 kB
/** * Options for customizing the debounce function behavior */ export interface IDebounceOptions { /** * If true, the debounced function will be invoked on the leading edge of the timeout * instead of the trailing edge */ leading?: boolean; /** * If true, the debounced function will be invoked on the trailing edge of the timeout */ trailing?: boolean; /** * Maximum time the debounced function is allowed to be delayed before it's invoked */ maxWait?: number; } /** * A debounced function that can be invoked, cancelled, and flushed */ export interface IDebouncedFunction<T extends (...args: any[]) => any> { /** * Invokes the debounced function */ (...args: Parameters<T>): ReturnType<T> | undefined; /** * Cancels any pending invocation of the debounced function */ cancel: () => void; /** * Immediately invokes any pending debounced function call */ flush: () => ReturnType<T> | undefined; /** * Returns true if there's a pending debounced function call */ isPending: () => boolean; } /** * Creates a debounced function that delays invoking func until after wait milliseconds have elapsed * since the last time the debounced function was invoked. * * The debounced function comes with methods to cancel delayed func invocations and to flush them immediately. * Provide options to indicate whether func should be invoked on the leading and/or trailing edge of the wait timeout. * * @param func The function to debounce * @param wait The number of milliseconds to delay * @param options The options object with leading, trailing, and maxWait properties * @returns A debounced version of the function with cancel, flush, and isPending methods */ export declare function debounce<T extends (...args: any[]) => any>(func: T, wait?: number, options?: IDebounceOptions): IDebouncedFunction<T>;