@bnidev/js-utils
    Preparing search index...

    Function wait

    • Waits for a specified number of milliseconds.

      Parameters

      • ms: number

        The number of milliseconds to wait.

      Returns Promise<void>

      A promise that resolves after the specified time.

      This utility is useful for creating delays in asynchronous operations, such as waiting for a certain condition to be met or pacing operations. It can be used in conjunction with async/await syntax for cleaner code.

      // ES Module
      import { wait } from '@bnidev/js-utils'

      // CommonJS
      const { wait } = require('@bnidev/js-utils')
      // Wait for 2 seconds
      await wait(2000)
      console.log('2 seconds have passed')