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

    Function until

    • Polls a condition until it returns true, a timeout elapses, or the signal is aborted.

      轮询直到条件返回 true、超时或信号被中止。

      Parameters

      • condition: () => boolean | Promise<boolean>

        The function to evaluate. It can return a boolean or a promise of a boolean. / 要评估的函数,可以返回布尔值或布尔值的 promise

      • options: UntilOptions = {}

        The options for the polling. / 轮询的配置项

        • Optionalinterval?: number

          The interval between condition checks in milliseconds.

          两次条件检查之间的间隔毫秒数

          100
          
        • Optionalsignal?: AbortSignal

          The signal to abort the polling.

          中止轮询的信号

        • Optionaltimeout?: number

          The maximum time in milliseconds to wait before rejecting with a TimeoutError.

          在抛出 TimeoutError 之前等待的最大毫秒数

      Returns Promise<void>

      A promise that resolves when the condition becomes true. / 条件为 true 时解析的 promise

      If interval is negative. / 如果 interval 为负数

      If the polling is aborted via the signal. / 如果通过信号中止轮询

      If timeout elapses before the condition becomes true. / 如果条件为 true 前已超时

      • sleep — for delaying between checks
      • sleep — 用于在检查之间延迟
      await until(() => file.ready, { interval: 100, timeout: 5000 });