function T(r, o, i = {}) {
  const {
    check: u = (e) => !!e,
    interval: c = 100,
    maxRetry: l = 1 / 0,
    onTimeout: a
  } = i;
  let m = 0, t = null;
  const n = () => {
    const e = r();
    if (u(e)) {
      o(e), t && clearTimeout(t);
      return;
    }
    if (++m >= l) {
      t && clearTimeout(t), a?.();
      return;
    }
    t = window.setTimeout(n, c);
  };
  return n(), () => {
    t && clearTimeout(t);
  };
}
export {
  T as retryUntil
};
