Skip to main content
Module

x/retry/retry/utils/tools.ts

Re-execute a function until it does not throw an error or execute a function with a timeout.
Very Popular
Latest
File
import { UNTIL } from "../options.ts";import { retry, retryAsync } from "../retry.ts";import { RetryUtilsOptions } from "./options.ts";
export const retryHof = <RETURN_TYPE>(until: UNTIL<RETURN_TYPE>) => ( fn: () => RETURN_TYPE, retryOptions?: RetryUtilsOptions, ): Promise<RETURN_TYPE> => retry(fn, { ...retryOptions, until });
export const retryAsyncHof = <RETURN_TYPE>(until: UNTIL<RETURN_TYPE>) => ( fn: () => Promise<RETURN_TYPE>, retryOptions?: RetryUtilsOptions, ): Promise<RETURN_TYPE> => retryAsync(fn, { ...retryOptions, until });