Skip to content

wait

function wait(ms): Promise<void>;

Defined in: wait.ts:18

Sleep for a given amount of time.

If you pass a value, it resolves with that value after the delay (keeping the type).

Parameter Type
ms number

Promise<void>

Delay a side effect

await wait(250);
console.log("250ms later");

Delay a typed value

const value = await wait(100, { ok: true as const });
// value: { ok: true }
function wait<T>(ms, value): Promise<T>;

Defined in: wait.ts:19

Sleep for a given amount of time.

If you pass a value, it resolves with that value after the delay (keeping the type).

Type Parameter
T
Parameter Type
ms number
value T

Promise<T>

Delay a side effect

await wait(250);
console.log("250ms later");

Delay a typed value

const value = await wait(100, { ok: true as const });
// value: { ok: true }