shelving
Version:
Toolkit for using data in JavaScript.
28 lines (27 loc) • 910 B
TypeScript
import type { Callback } from "./callback.js";
/**
* Create a new Timeout.
*
* Wrapper for `setTimeout()` that...
* - Keeps track of the reference returned from `setTimeout()`
* - Clears the any existing timeout when a new timeout is set.
* - Allows a default delay to be set that is applied to all new timeouts that don't have a delay set.
*
* @param ms The default delay for any created timeouts (in ms).
*/
export declare class Timeout {
private _callback;
private _ms;
private _timeout;
constructor(callback?: Callback | undefined, ms?: number);
/** Is a timeout currently set? */
get exists(): boolean;
/**
* Cancel any existing timeout and set a new one.
* @param callback
* @param ms The delay for this timeout (in ms).
*/
set(callback?: Callback | undefined, ms?: number): void;
/** Cancel any existing timeout.. */
clear(): void;
}