plainfp - v0.1.0
    Preparing search index...

    Function retry

    • Invoke factory repeatedly until it produces ok or times attempts are exhausted. Returns the last result.

      Factories must return a ResultAsync. If one rejects (rather than resolving to err), the rejection propagates immediately and no further retries are attempted — wrap throwing code with fromPromise/fromAsync so failures become typed err values.

      Type Parameters

      • T
      • E

      Parameters

      Returns ResultAsyncType<T, E>

      RangeError if times < 1.

      const user = await retry(
      () => fromPromise(fetchUser(id), e => ({ code: "NETWORK", cause: e })),
      { times: 3, delayMs: 200, backoff: "exponential" },
      )