@febin52/async-retry-lite
v1.0.2
Published
Resilient exponential-backoff retry utility for async functions & fetch with zero dependencies.
Maintainers
Readme
🔄 @febin52/async-retry-lite
Resilient exponential-backoff retry utility for async functions & fetch requests with zero dependencies.
Automatically retry failed asynchronous operations, HTTP fetch requests, or database queries with customizable exponential backoff delays.
🚀 Features
- ⚡ Zero Dependencies: Lightweight promise wrapper.
- 📈 Exponential Backoff: Configurable retry counts, initial delays, and delay multipliers.
- 🪝 On-Retry Hooks: Monitor failure attempts in real-time.
📦 Installation
npm install @febin52/async-retry-lite💡 Usage
import { retry } from '@febin52/async-retry-lite';
const data = await retry(
async (attempt) => {
console.log(`Attempt #${attempt}`);
const res = await fetch('https://api.example.com/data');
if (!res.ok) throw new Error('API Error');
return res.json();
},
{
retries: 3,
delay: 200,
factor: 2,
onRetry: (err, attempt) => console.warn(`Retry attempt ${attempt} due to:`, err.message)
}
);🔗 Links
- NPM Package: https://www.npmjs.com/package/@febin52/async-retry-lite
- GitHub Repository: https://github.com/febin52/async-retry-lite
- Issue Tracker: https://github.com/febin52/async-retry-lite/issues
📄 License
MIT © Febin Francis
