vigor-fetch 1.0.8 → 1.0.10
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/README.md +25 -13
- package/package.json +12 -4
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
- 🛡️ **Smart Resilience:** Automatically handles 429 errors by respecting `Retry-After` headers.
|
|
8
8
|
- 📈 **Exponential Backoff & Jitter:** Prevents server hammering by increasing wait times with random variation.
|
|
9
9
|
- ⚡ **Zero Dependencies:** Built using native Fetch API and AbortController.
|
|
10
|
+
- ⚡ **Tiny footprint** (~3 KB)
|
|
10
11
|
- 🎯 **Fully Type-Safe:** Written in TypeScript for excellent developer experience and auto-completion.
|
|
11
12
|
- 🚦 **Concurrency Control**: Execute bulk requests with a global limit and inter-request jitter using the VigorAll engine.
|
|
12
13
|
- 🎯 **Immutable Chaining**: Every configuration method returns a new instance, making it perfect for base templates and functional patterns.
|
|
@@ -18,9 +19,28 @@ npm install vigor-fetch
|
|
|
18
19
|
|
|
19
20
|
```
|
|
20
21
|
|
|
22
|
+
## Why Vigor?
|
|
23
|
+
|
|
24
|
+
| Feature | Vigor | Axios | Native fetch |
|
|
25
|
+
|-------|------|------|-------------|
|
|
26
|
+
| Built-in Retry | ✅ | ❌ | ❌ |
|
|
27
|
+
| Rate-limit handling | ✅ | ❌ | ❌ |
|
|
28
|
+
| Concurrency control | ✅ | ❌ | ❌ |
|
|
29
|
+
| Zero dependencies | ✅ | ❌ | ✅ |
|
|
30
|
+
| Immutable request builder | ✅ | ❌ | ❌ |
|
|
31
|
+
|
|
32
|
+
## Use Cases
|
|
33
|
+
|
|
34
|
+
**Vigor is useful when:**
|
|
35
|
+
|
|
36
|
+
- Your API frequently returns 429 (Too Many Requests)
|
|
37
|
+
- You need automatic retry with exponential backoff
|
|
38
|
+
- You want concurrency control for batch requests
|
|
39
|
+
- You prefer immutable request builders
|
|
40
|
+
|
|
21
41
|
## 🛠️ API References
|
|
22
42
|
|
|
23
|
-
1. **
|
|
43
|
+
1. **vigor.fetch(origin)**
|
|
24
44
|
|
|
25
45
|
| Method | Type | Default | Description
|
|
26
46
|
| :--- | :--- | :--- | :--- |
|
|
@@ -58,9 +78,7 @@ npm install vigor-fetch
|
|
|
58
78
|
|
|
59
79
|
```javascript
|
|
60
80
|
|
|
61
|
-
import
|
|
62
|
-
|
|
63
|
-
const vigor = new Vigor();
|
|
81
|
+
import vigor from 'vigor-fetch';
|
|
64
82
|
|
|
65
83
|
const data = await vigor.fetch("https://api.example.com")
|
|
66
84
|
.path("/v1/users")
|
|
@@ -80,9 +98,7 @@ const data = await vigor.fetch("https://api.example.com")
|
|
|
80
98
|
|
|
81
99
|
```javascript
|
|
82
100
|
|
|
83
|
-
import
|
|
84
|
-
|
|
85
|
-
const vigor = new Vigor();
|
|
101
|
+
import vigor from 'vigor-fetch';
|
|
86
102
|
|
|
87
103
|
const apiClient = vigor.fetch("https://api.myapp.com")
|
|
88
104
|
.headers({ "Content-Type": "application/json" })
|
|
@@ -98,9 +114,7 @@ const settings = await apiClient.path("/settings").request();
|
|
|
98
114
|
|
|
99
115
|
```javascript
|
|
100
116
|
|
|
101
|
-
import
|
|
102
|
-
|
|
103
|
-
const vigor = new Vigor();
|
|
117
|
+
import vigor from 'vigor-fetch';
|
|
104
118
|
|
|
105
119
|
const tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(id => () =>
|
|
106
120
|
vigor.fetch("https://api.com").path(`/data/${id}`).request()
|
|
@@ -118,9 +132,7 @@ const results = await vigor.all()
|
|
|
118
132
|
|
|
119
133
|
```javascript
|
|
120
134
|
|
|
121
|
-
import
|
|
122
|
-
|
|
123
|
-
const vigor = new Vigor();
|
|
135
|
+
import vigor from 'vigor-fetch';
|
|
124
136
|
|
|
125
137
|
const api = vigor.fetch("https://api.com")
|
|
126
138
|
.beforeRequest((opt) => {
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vigor-fetch",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Smart, zero-dependency HTTP client with self-healing retries for rate-limited servers.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Uav3537/Vigor"
|
|
11
|
+
},
|
|
8
12
|
"exports": {
|
|
9
13
|
".": {
|
|
10
14
|
"types": "./dist/index.d.ts",
|
|
@@ -14,19 +18,23 @@
|
|
|
14
18
|
},
|
|
15
19
|
"scripts": {
|
|
16
20
|
"prebuild": "rimraf dist",
|
|
17
|
-
"build": "rollup -c"
|
|
21
|
+
"build": "rollup -c",
|
|
22
|
+
"save": "node commit.js"
|
|
18
23
|
},
|
|
19
24
|
"files": [
|
|
20
25
|
"dist"
|
|
21
26
|
],
|
|
22
27
|
"keywords": [
|
|
23
28
|
"fetch",
|
|
24
|
-
"
|
|
29
|
+
"fetch retry",
|
|
30
|
+
"concurrency",
|
|
25
31
|
"retry",
|
|
26
32
|
"backoff",
|
|
27
33
|
"ratelimit",
|
|
34
|
+
"hooks",
|
|
28
35
|
"typescript",
|
|
29
|
-
"zero-dependency"
|
|
36
|
+
"zero-dependency",
|
|
37
|
+
"resilient HTTP client"
|
|
30
38
|
],
|
|
31
39
|
"author": "Uav1010",
|
|
32
40
|
"license": "MIT",
|