@pengzhanbo/utils - v3.4.1
    Preparing search index...

    Function timeout

    • Returns a promise that rejects with a TimeoutError after a specified delay.

      返回一个 promise,该 promise 在指定的延迟时间后拒绝,抛出一个 TimeoutError

      Parameters

      • ms: number

        the number of milliseconds to wait before rejecting the promise. 超时的毫秒数

      Returns Promise<never>

      Throws a TimeoutError after the specified delay.

      @example
      

      try { await timeout(1000); // Timeout exception after 1 second } catch (error) { console.error(error); // Will log 'The operation was timed out' }