ChemPare Documentation - v0.0.0
    Preparing search index...

    Function sleep

    • Creates a promise that resolves after the specified delay. Useful for adding delays in async operations or rate limiting.

      Parameters

      • ms: number

        The number of milliseconds to sleep

      Returns Promise<unknown>

      A promise that resolves after the specified delay

      async function example() {
      console.log("Start");
      await sleep(1000); // Waits 1 second
      console.log("End"); // Prints after delay
      }

      // For rate limiting:
      for (const item of items) {
      await processItem(item);
      await sleep(100); // Wait 100ms between items
      }