Skip to content

delay

Get Promise which resolves after specified number of milliseconds.

delay function

ts
function delay(ms: number): Promise<void>

Create a promise which resolves after specified number of milliseconds.

Parameters

  • ms: number Number of milliseconds to delay the promise.

Return Promise<void>

A promise which resolves after the specified milliseconds.


ts
function delay<TRes>(ms: number, value: TRes | PromiseLike<TRes>): Promise<TRes>

Create a promise which resolves given value after specified number of milliseconds.

Type Parameters

  • TRes Type of the value that will be resolved.

Parameters

  • ms: number Number of milliseconds to delay the promise.
  • value: TRes | PromiseLike<TRes> A value to resolve in the returned promise.

Return Promise<TRes>

A promise that resolve the given value after the specified milliseconds.

MIT License, Made with ❤️