Skip to content

delayed

delayed<T>(ms: number, result: T): Promise<T>

Defined in: extras/delay.ts:32

Returns a promise that resolves with the given result after a delay.

Use cases:

  • Simulating asynchronous operations in tests
  • Creating time-based effects in applications
  • Returning a value after a delay without blocking the main thread
Type ParameterDescription
TThe type of the result
ParameterTypeDescription
msnumberMilliseconds to delay
resultTValue to resolve after the delay

Promise<T>

Promise that resolves with the result after the delay

await delayed(1000, 'done'); // Resolves with 'done' after 1 second