UNPKG

feats

Version:

A comprehensive TypeScript utility library featuring fluent text building, type-safe switching, duration utilities, React hooks, and extended array/object prototypes for modern JavaScript development.

28 lines (27 loc) 940 B
/** * Represents a timeout controller with manual control. * - `set` schedules a new timeout (clearing any existing one). * - `clear` cancels the current timeout if set. * - `dispatch` triggers the timeout callback immediately and clears it. */ export interface Timeout { /** * Sets a new timeout with the given handler and time (in ms). * Automatically clears any previously set timeout before setting the new one. */ set: (handler: VoidFunction, time: number) => void; /** * Clears the currently scheduled timeout, if any. */ clear: VoidFunction; /** * Immediately invokes the stored timeout callback and clears the timeout. * Does nothing if no timeout is set. */ dispatch: VoidFunction; } /** * React hook for managing a single timeout with manual control. * Automatically clears the timeout on component unmount. */ export declare function useTimeout(): Timeout;