UNPKG

toosoon-utils

Version:
42 lines (41 loc) 1.49 kB
/** * No-op function */ export declare const noop: () => void; /** * Promise wrapped setTimeout * * @param {number} [delay=0] Time to wait (in milliseconds) * @returns {Promise} */ export declare function wait(delay?: number): Promise<void>; /** * Check if a value is defined * * @template {unknown} [T=unknown] * @param {T} value Value to check * @returns {boolean} `true` if the given value is defined, `false` otherwise */ export declare function isDefined<T = unknown>(value: T): value is Exclude<T, undefined | null>; /** * Create a debounced function that delays the execution of a given callback until a specified delay time has passed since the last call * * @template {Function} T * @param {T} callback Function to debounce * @param {number} delay Delay (in milliseconds) * @returns {T} Debounced function */ export declare function debounce<T extends (...args: any[]) => void>(callback: T, delay: number): (...args: Parameters<T>) => void; /** * Create a throttled function that limits the execution of a given callback to once every specified limit time * * @template {Function} T * @param {T} callback Function to throttle * @param {number} limit Minimum interval between two calls (in milliseconds) * @returns {T} Throttled function */ export declare function throttle<T extends (...args: any[]) => void>(callback: T, limit: number): (...args: Parameters<T>) => void; /** * Polyfill for `now()` functions */ export declare let now: () => number;