UNPKG

retry-ts

Version:

Retry combinators for monadic actions that may fail

23 lines (22 loc) 643 B
/** * @since 0.1.4 */ import { fromTaskK } from 'fp-ts/es6/ReaderTask'; import * as T from './Task'; /** * Apply policy and delay by its amount if it results in a retry. * Returns updated status. * * @since 0.1.4 */ export var applyAndDelay = fromTaskK(T.applyAndDelay); /** * Retry combinator for actions that don't raise exceptions, but * signal in their type the outcome has failed. Examples are the * `Option`, `Either` and `EitherT` monads. * * @since 0.1.4 */ export function retrying(policy, action, check) { return function (r) { return T.retrying(policy, function (status) { return action(status)(r); }, check); }; }