jj
    Preparing search index...

    Function sleep

    • Returns a promise that resolves after the specified delay.

      Parameters

      • ms: number = 0

        The delay in milliseconds. Defaults to 0.

      Returns Promise<void>

      A promise that resolves after the delay.

      Uses setTimeout to delay execution. When used with 0ms, it defers execution to the next macro-task, allowing the event loop to cycle.

      await sleep(100)
      await sleep() // equivalent to setTimeout(..., 0)