retry-utils-testmetest 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js ADDED
@@ -0,0 +1 @@
1
+ module.exports={};
package/package.json CHANGED
@@ -1,9 +1 @@
1
- {
2
- "name": "retry-utils-testmetest",
3
- "version": "1.0.0",
4
- "description": "Retry utility functions with exponential backoff",
5
- "main": "src/index.js",
6
- "keywords": ["retry", "backoff", "utils", "async"],
7
- "author": "alexjoipamiba",
8
- "license": "MIT"
9
- }
1
+ {"name":"retry-utils-testmetest","version":"1.0.2","description":"Lightweight utility","main":"index.js","license":"MIT"}
package/README.md DELETED
@@ -1,6 +0,0 @@
1
- # retry-utils-testmetest
2
- Retry utility with exponential backoff.
3
- ```js
4
- const { retry } = require('retry-utils-testmetest');
5
- const result = await retry(() => fetch('https://api.example.com/data'), { attempts: 3 });
6
- ```
package/src/index.js DELETED
@@ -1,14 +0,0 @@
1
- async function retry(fn, opts = {}) {
2
- const { attempts = 3, delay = 1000, factor = 2 } = opts;
3
- let lastErr;
4
- for (let i = 0; i < attempts; i++) {
5
- try { return await fn(); }
6
- catch (e) {
7
- lastErr = e;
8
- if (i < attempts - 1)
9
- await new Promise(r => setTimeout(r, delay * Math.pow(factor, i)));
10
- }
11
- }
12
- throw lastErr;
13
- }
14
- module.exports = { retry };