TS-Scribe - v0.6.2
    Preparing search index...

    Function sleep

    • Pauses the execution for a specified number of milliseconds. This is useful when you want to introduce delays in asynchronous code, without blocking the event loop.


      Example:

      console.log("Start");
      await sleep(1000); // Pauses for 1 second
      console.log("End"); // Logs after 1 second

      Parameters

      • ms: number

        The number of milliseconds to pause execution.

      Returns Promise<void>

      A Promise that resolves after the specified time has passed.

      sleep(2000).then(() => console.log("2 seconds have passed")); // Logs after 2 seconds