wait
Call Signature
Section titled “Call Signature”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).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ms |
number |
Returns
Section titled “Returns”Promise<void>
Examples
Section titled “Examples”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 }Call Signature
Section titled “Call Signature”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ms |
number |
value |
T |
Returns
Section titled “Returns”Promise<T>
Examples
Section titled “Examples”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 }