UNPKG

redo.js

Version:

A simple but powerful library for your retrying operations.

21 lines (20 loc) 1.14 kB
interface RetryOperation { retryCount: number | "infinite"; retryDelay: number; retryCallback: (payload?: any) => any; onErrorCallback: (error?: Error, currentRetryCount?: number) => void; onSuccessCallback: (response?: any) => void; afterLastAttemptErrorCallback?: (error?: any) => void; incrementalDelayFactor?: number; } interface RetryAsyncOperationExtended extends RetryOperation { retryAsyncCallback: () => Promise<void>; } type RetryAsyncOperation = Omit<RetryAsyncOperationExtended, "retryCallback">; declare function retryOperation({ retryCallback, onErrorCallback, onSuccessCallback, afterLastAttemptErrorCallback, retryCount, // Default retry count is 3 retryDelay, // Default is 1 second incrementalDelayFactor, }: RetryOperation): Promise<void>; declare function retryAsyncOperation({ retryAsyncCallback, onErrorCallback, onSuccessCallback, afterLastAttemptErrorCallback, retryCount, // Default retry count is 3 retryDelay, // Default is 1 second incrementalDelayFactor, }: RetryAsyncOperation): Promise<void>; export { retryOperation, retryAsyncOperation, RetryOperation, RetryAsyncOperation, };