@superutils/fetch 1.1.0 → 1.1.1
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 +11 -9
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -201,13 +201,15 @@ const saveProductThrottled = fetch.post.deferred(
|
|
|
201
201
|
)
|
|
202
202
|
// Simulate a user typing quickly, triggering multiple saves.
|
|
203
203
|
console.log('User starts typing...')
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
saveProductThrottled({ title: 'iPhone
|
|
207
|
-
|
|
208
|
-
saveProductThrottled({ title: 'iPhone 15
|
|
209
|
-
|
|
210
|
-
saveProductThrottled({ title: 'iPhone 15 Pro
|
|
204
|
+
|
|
205
|
+
// Executed immediately (leading edge)
|
|
206
|
+
saveProductThrottled({ title: 'iPhone' })
|
|
207
|
+
// Ignored (within 1000ms throttle window)
|
|
208
|
+
PromisE.delay(200, () => saveProductThrottled({ title: 'iPhone 15' }))
|
|
209
|
+
// Ignored
|
|
210
|
+
PromisE.delay(300, () => saveProductThrottled({ title: 'iPhone 15 Pro' }))
|
|
211
|
+
// Queued to execute on the trailing edge
|
|
212
|
+
PromisE.delay(400, () => saveProductThrottled({ title: 'iPhone 15 Pro Max' }))
|
|
211
213
|
// Outcome:
|
|
212
214
|
// The first call ('iPhone') is executed immediately.
|
|
213
215
|
// The next two calls are ignored by the throttle.
|
|
@@ -229,11 +231,11 @@ let currentRefreshToken = ''
|
|
|
229
231
|
const requestNewToken = fetch.post.deferred(
|
|
230
232
|
{
|
|
231
233
|
delayMs: 300, // debounce delay
|
|
232
|
-
onResult: ({
|
|
234
|
+
onResult: ({ refreshToken = '' }) => {
|
|
233
235
|
console.log(
|
|
234
236
|
`Auth token successfully refreshed at ${new Date().toISOString()}`,
|
|
235
237
|
)
|
|
236
|
-
currentRefreshToken =
|
|
238
|
+
currentRefreshToken = refreshToken
|
|
237
239
|
},
|
|
238
240
|
},
|
|
239
241
|
'https://dummyjson.com/auth/refresh', // Default URL
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "A lightweight `fetch` wrapper for browsers and Node.js, designed to simplify data fetching and reduce boilerplate.",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@superutils/core": "^1.1.1",
|
|
9
|
-
"@superutils/promise": "^1.1.
|
|
9
|
+
"@superutils/promise": "^1.1.1"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"name": "@superutils/fetch",
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@superutils/core": "^1.1.1",
|
|
28
|
-
"@superutils/promise": "^1.1.
|
|
28
|
+
"@superutils/promise": "^1.1.1"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"sideEffects": false,
|
|
46
46
|
"type": "module",
|
|
47
47
|
"types": "dist/index.d.ts",
|
|
48
|
-
"version": "1.1.
|
|
48
|
+
"version": "1.1.1"
|
|
49
49
|
}
|