Sleep

Pauses the execution for a specified duration.

CategoryFunctions
AuthorPol Gubau
Since1.0.0
Last Updated2025-03-15
TypeAsync
CompatibilityUniversal

Example

  • Input

    await sleep(1000)

    Output:

    Pauses execution for 1000 milliseconds.

Return

Resolves after the specified duration.

Type: void

Props

NameTypeDefaultRequiredDescription
msnumber | `${number}ms`nullYesThe duration to sleep, in milliseconds or a string representing milliseconds.

Notes

The `ms` parameter can be either a number (in milliseconds) or a string with the format `${number}ms`.

Tags

  • sleep
  • delay
  • timeout

Related