• Sleeps for a specified duration, with optional intervals and callbacks. Returns a cancellable promise that resolves when the sleep is complete.

    • duration (required): The duration, in milliseconds, to sleep for.
    • interval (optional): The interval, in milliseconds, at which to execute the callback. Defaults to undefined.
    • callback (optional): The callback function to execute at each interval. Defaults to undefined.

    Type Parameters

    • T extends number

    Parameters

    Returns {
        cancel: (() => void);
        promise: Promise<void>;
    }

    • cancel: (() => void)
        • (): void
        • Returns void

    • promise: Promise<void>