@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.
Files changed (2) hide show
  1. package/README.md +11 -9
  2. 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
- saveProductThrottled({ title: 'iPhone' }) // Executed immediately (leading edge)
205
- await PromisE.delay(200)
206
- saveProductThrottled({ title: 'iPhone 15' }) // Ignored (within 1000ms throttle window)
207
- await PromisE.delay(300)
208
- saveProductThrottled({ title: 'iPhone 15 Pro' }) // Ignored
209
- await PromisE.delay(400)
210
- saveProductThrottled({ title: 'iPhone 15 Pro Max' }) // Queued to execute on the trailing edge
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: ({ token = '' }) => {
234
+ onResult: ({ refreshToken = '' }) => {
233
235
  console.log(
234
236
  `Auth token successfully refreshed at ${new Date().toISOString()}`,
235
237
  )
236
- currentRefreshToken = token
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.0"
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.0"
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.0"
48
+ "version": "1.1.1"
49
49
  }