Skip to main content

Function: sleep()

sleep<T>(delay?, value?, options?): Promise<T>

import {
setTimeout,
} from 'node:timers/promises';

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

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

Type Parameters

T

T = void

Parameters

delay?

number

The number of milliseconds to wait before fulfilling the promise. Default: 1.

value?

T

A value with which the promise is fulfilled.

options?

TimerOptions

Returns

Promise<T>

Since

v15.0.0