@jiminp/tooltool
    Preparing search index...

    Function sleep

    • Returns a promise that settles after a timer delay without blocking other work.

      Parameters

      • time_ms: number

        Finite duration in milliseconds; nonpositive values yield once asynchronously.

      Returns Promise<void>

      A promise that resolves when the final timer completes.

      If time_ms is not finite.

      Timer scheduling is approximate. Each wait uses the remaining duration:

      • Up to 1000 ms: wait once, then return without rechecking the clock.
      • Up to 10000 ms: wait for the remainder minus 500 ms.
      • Longer: wait for 75% of the remainder, capped at 2 ** 31 - 1 ms.

      After non-final waits, recompute the remainder using performance.now(). Trust the final timer, including platform truncation of fractional milliseconds.

      await sleep(500); // waits approximately 500 ms