Skip to main content

setTimeout

function setTimeout
Jump to headingsetTimeout<T = void>(
delay?: number,
value?: T,
options?: TimerOptions,
): Promise<T>
import {
  setTimeout,
} from 'node:timers/promises';

const res = await setTimeout(100, 'result');

console.log(res);  // Prints 'result'

Type Parameters Jump to heading

Parameters Jump to heading

optional
Jump to headingdelay: number = 1

The number of milliseconds to wait before fulfilling the promise.

optional
Jump to headingvalue: T

A value with which the promise is fulfilled.

Return Type Jump to heading

Promise<T>
Back to top