UNPKG

@mebsly/retry

Version:

A flexible and configurable retry mechanism for JavaScript functions and fetch requests with exponential delay

16 lines (13 loc) 384 B
Lightweight retry for JavaScript and fetch requests with exponential delay. Usage: https://github.com/mebsly/retry ```js const retry = require('@mebsly/retry'); // Retry a function retry(() => someFunction()); // Retry with custom options retry(() => someFunction(), { retries: 5, delay: 1000, maxDelay: 5000, shouldRetry: (err) => err.code === 'ECONNRESET' }); ```