@vyriy/retry
v0.8.9
Published
Retry utility for Vyriy projects
Readme
@vyriy/retry
Part of Vyriy - a calm architecture toolkit for TypeScript, React, SSR, SSG, APIs, and cloud-ready apps.
Full documentation: https://vyriy.dev/docs/retry/
Retry utility for Vyriy projects.
Purpose
This package provides a small wrapper for retrying an async handler a fixed number of times with an optional delay between attempts.
Install
With npm:
npm install @vyriy/retryWith Yarn:
yarn add @vyriy/retryUsage
import { retry } from '@vyriy/retry';
const result = await retry(async () => fetch('https://example.com/data').then((response) => response.json()), {
retries: 3,
delay: 250,
});Exports
The package exposes both the root entry and the direct utility module:
import { retry } from '@vyriy/retry';API
retry(handler, options?)retrieshandleruntil it succeeds or retries are exhausted.options.retriescontrols how many retries happen after the first failure.options.delaysets the delay between retries in milliseconds.
