augment-vir - v31.32.2
    Preparing search index...

    Function retry

    • Calls callback until it doesn't throw an error or throws an error when maxRetries is reached. Similar to the waitUntil guard from '@augment-vir/assert' but doesn't check the callback's output.

      Type Parameters

      • const T
      • const Duration extends
            | undefined
            | _RequireAtLeastOne<
                RequiredAndNotNull<Partial<Record<DurationUnit, undefined | number>>>,
                DurationUnit,
            > = undefined

      Parameters

      Returns IsEqual<Duration, undefined> extends true ? T : Promise<Awaited<T>>

      import {callWithRetries} from '@augment-vir/common';

      const result = callWithRetries(5, () => {
      if (Math.random() < 0.5) {
      return 'done';
      } else {
      throw new Error();
      }
      });