Skip to content

Latest commit

 

History

History
119 lines (85 loc) · 3.08 KB

File metadata and controls

119 lines (85 loc) · 3.08 KB

"quickjs:timers" (namespace)

declare module "quickjs:timers" {
  export type Timer = {
    [Symbol.toStringTag]: "Timer";
  };
  export function setTimeout(func: (...args: any) => any, delay: number): Timer;
  export function clearTimeout(handle: Timer): void;
  export function setInterval(
    func: (...args: any) => any,
    delay: number,
  ): Timer;
  export function clearInterval(handle: Timer): void;
  export function sleepAsync(delay_ms: number): Promise<void>;
}

"quickjs:timers".Timer (exported type)

type Timer = {
  [Symbol.toStringTag]: "Timer";
};

"quickjs:timers".setTimeout (exported function)

Call the function func after delay ms. Return a handle to the timer.

export function setTimeout(func: (...args: any) => any, delay: number): Timer;

"quickjs:timers".clearTimeout (exported function)

Cancel a timer.

export function clearTimeout(handle: Timer): void;

"quickjs:timers".setInterval (exported function)

Call the function func repeatedly, with delay ms between each call. Return a handle to the timer.

export function setInterval(func: (...args: any) => any, delay: number): Timer;

"quickjs:timers".clearInterval (exported function)

Cancel an interval timer.

export function clearInterval(handle: Timer): void;

"quickjs:timers".sleepAsync (exported function)

Asynchronous sleep. Returns a Promise that resolves after delay_ms milliseconds. Intended for use with await.

export function sleepAsync(delay_ms: number): Promise<void>;

Timer (type)

An opaque timer handle returned by setTimeout/setInterval

declare type Timer = import("quickjs:timers").Timer;

setTimeout (value)

Call the function func after delay ms. Return a handle to the timer.

var setTimeout: typeof import("quickjs:timers").setTimeout;

clearTimeout (value)

Cancel a timer.

var clearTimeout: typeof import("quickjs:timers").clearTimeout;

setInterval (value)

Call the function func repeatedly, with delay ms between each call. Return a handle to the timer.

var setInterval: typeof import("quickjs:timers").setInterval;

clearInterval (value)

Cancel an interval timer.

var clearInterval: typeof import("quickjs:timers").clearInterval;