GuobaGuoba Utils

sleep

@guoba-ai/utils / async / sleep

Function: sleep()

function sleep(ms): Promise<void>;

Defined in: async.ts:17

Wait for the given number of milliseconds.

Parameters

ms

number

The number of milliseconds to wait

Returns

Promise<void>

A promise that resolves after ms milliseconds

Example

await sleep(100) // resolves after ~100ms

await sleep(0) // yields to a later timer tick

await Promise.all([sleep(50), fetchData()])

Warning

Timer resolution depends on the JavaScript runtime and event loop load, so the delay is not exact.

On this page