@alwatr/fetch 0.21.0 → 0.22.0
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/CHANGELOG.md +15 -0
- package/README.md +13 -40
- package/fetch.d.ts +5 -21
- package/fetch.d.ts.map +1 -1
- package/fetch.js +40 -88
- package/fetch.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.22.0](https://github.com/AliMD/alwatr/compare/v0.21.0...v0.22.0) (2022-11-20)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **fetch:** \_handleRetryPattern ([fe4ac12](https://github.com/AliMD/alwatr/commit/fe4ac12b4ad3086d44e545591c767cb322e32b8d))
|
|
11
|
+
- **fetch:** bodyJson issue ([5d8d6fa](https://github.com/AliMD/alwatr/commit/5d8d6fa4a0f608c2c5ed583aa54de9b836daaa5f))
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- **fetch:** support nodejs ([2ed2ef4](https://github.com/AliMD/alwatr/commit/2ed2ef42e9f204d4896ada4e20b839cfabdc7284))
|
|
16
|
+
|
|
17
|
+
### Performance Improvements
|
|
18
|
+
|
|
19
|
+
- **fetch:** Improve performance and decrease memory usage ([7c29333](https://github.com/AliMD/alwatr/commit/7c293339215bea3a5013effe4aea5b6267a7a75e))
|
|
20
|
+
|
|
6
21
|
# [0.21.0](https://github.com/AliMD/alwatr/compare/v0.20.0...v0.21.0) (2022-11-13)
|
|
7
22
|
|
|
8
23
|
**Note:** Version bump only for package @alwatr/fetch
|
package/README.md
CHANGED
|
@@ -4,26 +4,29 @@ Enhanced fetch API with cache strategy, retry pattern, timeout, helper methods a
|
|
|
4
4
|
|
|
5
5
|
## Example usage
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import {getJson} from 'https://esm.run/@alwatr/fetch';
|
|
7
|
+
### `fetch(options: FetchOptions): Promise<Response>`
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
image: string;
|
|
15
|
-
}
|
|
9
|
+
It's a wrapper around the browser's `fetch` function that adds retry pattern with timeout and cacheStrategy.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import {fetch} from 'https://esm.run/@alwatr/fetch';
|
|
16
13
|
|
|
17
|
-
const
|
|
14
|
+
const response = await fetch({
|
|
18
15
|
url: '/api/products',
|
|
19
16
|
queryParameters: {limit: 10},
|
|
20
17
|
timeout: 5_000,
|
|
21
18
|
retry: 3,
|
|
22
19
|
cacheStrategy: 'stale_while_revalidate',
|
|
23
20
|
});
|
|
21
|
+
|
|
22
|
+
if (!response.ok) throw new Error('fetch_failed');
|
|
23
|
+
|
|
24
|
+
const productList = await response.json();
|
|
25
|
+
|
|
26
|
+
console.log(productList);
|
|
24
27
|
```
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
### Fetch Options
|
|
27
30
|
|
|
28
31
|
`FetchOptions` inherited from the [fetch standard parameters](https://developer.mozilla.org/en-US/docs/Web/API/fetch#parameters) and some other...
|
|
29
32
|
|
|
@@ -48,33 +51,3 @@ const productList = await getJson<Record<string, ProductInterface>>({
|
|
|
48
51
|
- `cacheStorageName`: Cache storage custom name (default `alwatr_fetch_cache`).
|
|
49
52
|
|
|
50
53
|
[Read more about standard cache strategies](https://developer.chrome.com/docs/workbox/caching-strategies-overview/#caching-strategies)
|
|
51
|
-
|
|
52
|
-
## API
|
|
53
|
-
|
|
54
|
-
### `fetch(options: FetchOptions): Promise<Response>`
|
|
55
|
-
|
|
56
|
-
It's a wrapper around the browser's `fetch` function that adds retry pattern with timeout and cacheStrategy.
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
const response = await fetch({
|
|
60
|
-
url: '/api/products',
|
|
61
|
-
queryParameters: {limit: 10},
|
|
62
|
-
timeout: 5_000,
|
|
63
|
-
retry: 3,
|
|
64
|
-
cacheStrategy: 'stale_while_revalidate',
|
|
65
|
-
});
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### `getJson<T>(options: FetchOptions): Promise<T>`
|
|
69
|
-
|
|
70
|
-
It fetches a JSON file from a URL, and returns the parsed data.
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
const productList = await getJson<ProductResponse>({
|
|
74
|
-
url: '/api/products',
|
|
75
|
-
queryParameters: {limit: 10},
|
|
76
|
-
timeout: 5_000,
|
|
77
|
-
retry: 3,
|
|
78
|
-
cacheStrategy: 'stale_while_revalidate',
|
|
79
|
-
});
|
|
80
|
-
```
|
package/fetch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type CacheStrategy = 'network_only' | 'network_first' | 'cache_only' | 'cache_first' | 'stale_while_revalidate';
|
|
2
|
+
export type CacheDuplicate = 'never' | 'always' | 'until_load' | 'auto';
|
|
3
3
|
export interface FetchOptions extends RequestInit {
|
|
4
4
|
/**
|
|
5
5
|
* Request URL.
|
|
@@ -11,6 +11,9 @@ export interface FetchOptions extends RequestInit {
|
|
|
11
11
|
method: string;
|
|
12
12
|
/**
|
|
13
13
|
* A timeout for the fetch request.
|
|
14
|
+
* Set `0` for disable it.
|
|
15
|
+
*
|
|
16
|
+
* Use with cation, you will have memory leak issue in nodejs.
|
|
14
17
|
*
|
|
15
18
|
* @default 10_000 ms
|
|
16
19
|
*/
|
|
@@ -67,25 +70,6 @@ export interface FetchOptions extends RequestInit {
|
|
|
67
70
|
*/
|
|
68
71
|
queryParameters?: Record<string, string | number | boolean>;
|
|
69
72
|
}
|
|
70
|
-
/**
|
|
71
|
-
* It fetches a JSON file from a URL, and returns the parsed data.
|
|
72
|
-
*
|
|
73
|
-
* Example:
|
|
74
|
-
*
|
|
75
|
-
* ```ts
|
|
76
|
-
* const productList = await getJson<ProductResponse>({
|
|
77
|
-
* url: '/api/products',
|
|
78
|
-
* queryParameters: {limit: 10},
|
|
79
|
-
* timeout: 10_000,
|
|
80
|
-
* retry: 3,
|
|
81
|
-
* cacheStrategy: 'stale_while_revalidate',
|
|
82
|
-
* cacheDuplicate: 'auto',
|
|
83
|
-
* });
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
export declare function getJson<ResponseType extends Record<string | number, unknown>>(_options: Partial<FetchOptions> & {
|
|
87
|
-
url: string;
|
|
88
|
-
}): Promise<ResponseType>;
|
|
89
73
|
/**
|
|
90
74
|
* It's a wrapper around the browser's `fetch` function that adds retry pattern, timeout, cacheStrategy,
|
|
91
75
|
* remove duplicates, etc.
|
package/fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["src/fetch.ts"],"names":[],"mappings":"AASA,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["src/fetch.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,eAAe,GAAG,YAAY,GAAG,aAAa,GAAG,wBAAwB,CAAC;AACvH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY,GAAG,MAAM,CAAC;AAExE,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;OASG;IACH,eAAe,EAAE,cAAc,CAAC;IAEhC;;;;;;;;;;OAUG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IAElD;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAAC;IAE5C;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CAC7D;AAOD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAIxF"}
|
package/fetch.js
CHANGED
|
@@ -5,49 +5,8 @@ alwatrRegisteredList.push({
|
|
|
5
5
|
version: '{{ALWATR_VERSION}}',
|
|
6
6
|
});
|
|
7
7
|
let alwatrCacheStorage;
|
|
8
|
-
const cacheSupported = 'caches' in
|
|
8
|
+
const cacheSupported = 'caches' in globalThis;
|
|
9
9
|
const duplicateRequestStorage = {};
|
|
10
|
-
/**
|
|
11
|
-
* It fetches a JSON file from a URL, and returns the parsed data.
|
|
12
|
-
*
|
|
13
|
-
* Example:
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* const productList = await getJson<ProductResponse>({
|
|
17
|
-
* url: '/api/products',
|
|
18
|
-
* queryParameters: {limit: 10},
|
|
19
|
-
* timeout: 10_000,
|
|
20
|
-
* retry: 3,
|
|
21
|
-
* cacheStrategy: 'stale_while_revalidate',
|
|
22
|
-
* cacheDuplicate: 'auto',
|
|
23
|
-
* });
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export async function getJson(_options) {
|
|
27
|
-
const options = _processOptions(_options);
|
|
28
|
-
logger.logMethodArgs('getJson', { options });
|
|
29
|
-
const response = await _handleRemoveDuplicate(options);
|
|
30
|
-
let data;
|
|
31
|
-
try {
|
|
32
|
-
if (!response.ok) {
|
|
33
|
-
throw new Error('fetch_nok');
|
|
34
|
-
}
|
|
35
|
-
data = (await response.json());
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
logger.accident('getJson', 'response_json', 'response json error', {
|
|
39
|
-
retry: options.retry,
|
|
40
|
-
err,
|
|
41
|
-
});
|
|
42
|
-
if (options.retry > 1) {
|
|
43
|
-
data = await getJson(options);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
throw err;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return data;
|
|
50
|
-
}
|
|
51
10
|
/**
|
|
52
11
|
* It's a wrapper around the browser's `fetch` function that adds retry pattern, timeout, cacheStrategy,
|
|
53
12
|
* remove duplicates, etc.
|
|
@@ -68,7 +27,7 @@ export async function getJson(_options) {
|
|
|
68
27
|
export function fetch(_options) {
|
|
69
28
|
const options = _processOptions(_options);
|
|
70
29
|
logger.logMethodArgs('fetch', { options });
|
|
71
|
-
return
|
|
30
|
+
return _handleCacheStrategy(options);
|
|
72
31
|
}
|
|
73
32
|
/**
|
|
74
33
|
* Process fetch options and set defaults, etc.
|
|
@@ -100,7 +59,7 @@ function _processOptions(options) {
|
|
|
100
59
|
options.url += '?' + queryArray.join('&');
|
|
101
60
|
}
|
|
102
61
|
}
|
|
103
|
-
if (options.
|
|
62
|
+
if (options.bodyJson != null) {
|
|
104
63
|
options.body = JSON.stringify(options.bodyJson);
|
|
105
64
|
options.headers = {
|
|
106
65
|
...options.headers,
|
|
@@ -110,16 +69,16 @@ function _processOptions(options) {
|
|
|
110
69
|
return options;
|
|
111
70
|
}
|
|
112
71
|
/**
|
|
113
|
-
* Handle Remove Duplicates over `
|
|
72
|
+
* Handle Remove Duplicates over `_handleRetryPattern`.
|
|
114
73
|
*/
|
|
115
74
|
async function _handleRemoveDuplicate(options) {
|
|
116
75
|
if (options.removeDuplicate === 'never')
|
|
117
|
-
return
|
|
76
|
+
return _handleRetryPattern(options);
|
|
118
77
|
logger.logMethod('_handleRemoveDuplicate');
|
|
119
78
|
const cacheKey = `[${options.method}] ${options.url}`;
|
|
120
79
|
const firstRequest = duplicateRequestStorage[cacheKey] == null;
|
|
121
80
|
// We must cache fetch promise without await for handle other parallel requests.
|
|
122
|
-
duplicateRequestStorage[cacheKey] ?? (duplicateRequestStorage[cacheKey] =
|
|
81
|
+
duplicateRequestStorage[cacheKey] ?? (duplicateRequestStorage[cacheKey] = _handleRetryPattern(options));
|
|
123
82
|
try {
|
|
124
83
|
// For all requests need to await for clone responses.
|
|
125
84
|
const response = await duplicateRequestStorage[cacheKey];
|
|
@@ -137,11 +96,11 @@ async function _handleRemoveDuplicate(options) {
|
|
|
137
96
|
}
|
|
138
97
|
}
|
|
139
98
|
/**
|
|
140
|
-
* Handle Cache Strategy over `
|
|
99
|
+
* Handle Cache Strategy over `_handleRemoveDuplicate`.
|
|
141
100
|
*/
|
|
142
101
|
async function _handleCacheStrategy(options) {
|
|
143
102
|
if (options.cacheStrategy === 'network_only') {
|
|
144
|
-
return
|
|
103
|
+
return _handleRemoveDuplicate(options);
|
|
145
104
|
}
|
|
146
105
|
// else handle cache strategies!
|
|
147
106
|
logger.logMethod('_handleCacheStrategy');
|
|
@@ -155,7 +114,7 @@ async function _handleCacheStrategy(options) {
|
|
|
155
114
|
const cachedResponse = await cacheStorage.match(request);
|
|
156
115
|
if (cachedResponse != null)
|
|
157
116
|
return cachedResponse;
|
|
158
|
-
const response = await
|
|
117
|
+
const response = await _handleRemoveDuplicate(options);
|
|
159
118
|
if (response.ok) {
|
|
160
119
|
cacheStorage.put(request, response.clone());
|
|
161
120
|
}
|
|
@@ -169,7 +128,7 @@ async function _handleCacheStrategy(options) {
|
|
|
169
128
|
}
|
|
170
129
|
case 'network_first': {
|
|
171
130
|
try {
|
|
172
|
-
const networkResponse = await
|
|
131
|
+
const networkResponse = await _handleRemoveDuplicate(options);
|
|
173
132
|
if (networkResponse.ok) {
|
|
174
133
|
cacheStorage.put(request, networkResponse.clone());
|
|
175
134
|
}
|
|
@@ -184,7 +143,7 @@ async function _handleCacheStrategy(options) {
|
|
|
184
143
|
}
|
|
185
144
|
case 'stale_while_revalidate': {
|
|
186
145
|
const cachedResponse = await cacheStorage.match(request);
|
|
187
|
-
const fetchedResponsePromise =
|
|
146
|
+
const fetchedResponsePromise = _handleRemoveDuplicate(options);
|
|
188
147
|
fetchedResponsePromise.then((networkResponse) => {
|
|
189
148
|
if (networkResponse.ok) {
|
|
190
149
|
cacheStorage.put(request, networkResponse.clone());
|
|
@@ -196,7 +155,7 @@ async function _handleCacheStrategy(options) {
|
|
|
196
155
|
return cachedResponse || fetchedResponsePromise;
|
|
197
156
|
}
|
|
198
157
|
default: {
|
|
199
|
-
return
|
|
158
|
+
return _handleRemoveDuplicate(options);
|
|
200
159
|
}
|
|
201
160
|
}
|
|
202
161
|
}
|
|
@@ -204,45 +163,38 @@ async function _handleCacheStrategy(options) {
|
|
|
204
163
|
* Handle retry pattern over `_handleTimeout`.
|
|
205
164
|
*/
|
|
206
165
|
async function _handleRetryPattern(options) {
|
|
207
|
-
if (!(options.retry
|
|
166
|
+
if (!(options.retry > 1))
|
|
208
167
|
return _handleTimeout(options);
|
|
209
168
|
logger.logMethod('_handleRetryPattern');
|
|
169
|
+
options.retry--;
|
|
210
170
|
const externalAbortSignal = options.signal;
|
|
211
|
-
const retryFetch = async () => {
|
|
212
|
-
options.retry--;
|
|
213
|
-
options.signal = externalAbortSignal;
|
|
214
|
-
await _wait(options.retryDelay);
|
|
215
|
-
return _handleCacheStrategy(options); // maybe cache updated by another request ;)
|
|
216
|
-
};
|
|
217
171
|
try {
|
|
218
172
|
const response = await _handleTimeout(options);
|
|
219
|
-
if (
|
|
220
|
-
logger.
|
|
221
|
-
|
|
222
|
-
});
|
|
223
|
-
return retryFetch();
|
|
173
|
+
if (response.status >= 500) {
|
|
174
|
+
logger.incident('fetch', 'fetch_server_error', 'fetch server error ' + response.status);
|
|
175
|
+
throw new Error('fetch_server_error');
|
|
224
176
|
}
|
|
225
|
-
|
|
226
|
-
|
|
177
|
+
else
|
|
178
|
+
return response;
|
|
227
179
|
}
|
|
228
|
-
catch (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return retryFetch();
|
|
234
|
-
}
|
|
235
|
-
// else
|
|
236
|
-
throw reason;
|
|
180
|
+
catch (err) {
|
|
181
|
+
logger.accident('fetch', err?.name ?? 'fetch_failed', 'fetch failed and retry', { err });
|
|
182
|
+
await _wait(options.retryDelay);
|
|
183
|
+
options.signal = externalAbortSignal;
|
|
184
|
+
return _handleRetryPattern(options);
|
|
237
185
|
}
|
|
238
186
|
}
|
|
239
187
|
/**
|
|
240
188
|
* It's a wrapper around the browser's `fetch` with timeout.
|
|
241
189
|
*/
|
|
242
190
|
function _handleTimeout(options) {
|
|
191
|
+
if (options.timeout === 0) {
|
|
192
|
+
return globalThis.fetch(options.url, options);
|
|
193
|
+
}
|
|
194
|
+
// else
|
|
243
195
|
logger.logMethod('_handleTimeout');
|
|
244
196
|
return new Promise((resolved, reject) => {
|
|
245
|
-
//
|
|
197
|
+
// TODO: AbortController polyfill
|
|
246
198
|
const abortController = new AbortController();
|
|
247
199
|
const externalAbortSignal = options.signal;
|
|
248
200
|
options.signal = abortController.signal;
|
|
@@ -252,21 +204,21 @@ function _handleTimeout(options) {
|
|
|
252
204
|
}, options.timeout);
|
|
253
205
|
if (externalAbortSignal != null) {
|
|
254
206
|
// Respect external abort signal
|
|
255
|
-
externalAbortSignal.addEventListener('abort', () => {
|
|
256
|
-
abortController.abort(`external abort signal: ${externalAbortSignal.reason}`);
|
|
257
|
-
clearTimeout(timeoutId);
|
|
258
|
-
});
|
|
207
|
+
externalAbortSignal.addEventListener('abort', () => abortController.abort(), { once: true });
|
|
259
208
|
}
|
|
260
|
-
abortController.signal.addEventListener('abort', () => {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
});
|
|
265
|
-
|
|
209
|
+
// abortController.signal.addEventListener('abort', () => {
|
|
210
|
+
// logger.incident('fetch', 'fetch_abort_signal', 'fetch abort signal received', {
|
|
211
|
+
// reason: abortController.signal.reason,
|
|
212
|
+
// });
|
|
213
|
+
// });
|
|
214
|
+
globalThis
|
|
266
215
|
.fetch(options.url, options)
|
|
267
216
|
.then((response) => resolved(response))
|
|
268
217
|
.catch((reason) => reject(reason))
|
|
269
|
-
.finally(() =>
|
|
218
|
+
.finally(() => {
|
|
219
|
+
delete options.signal; // try to avoid memory leak in nodejs!
|
|
220
|
+
clearTimeout(timeoutId);
|
|
221
|
+
});
|
|
270
222
|
});
|
|
271
223
|
}
|
|
272
224
|
const _wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
package/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAElE,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;AAE5C,oBAAoB,CAAC,IAAI,CAAC;IACxB,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,oBAAoB;CAC9B,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,oBAAoB,EAAC,MAAM,gBAAgB,CAAC;AAElE,MAAM,MAAM,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;AAE5C,oBAAoB,CAAC,IAAI,CAAC;IACxB,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,oBAAoB;CAC9B,CAAC,CAAC;AAsFH,IAAI,kBAAyB,CAAC;AAC9B,MAAM,cAAc,GAAG,QAAQ,IAAI,UAAU,CAAC;AAE9C,MAAM,uBAAuB,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M,CAAC,CAAC,sCAAsC;YAC7D,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,KAAK,GAAG,CAAC,EAAU,EAAiB,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/fetch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Enhanced fetch API with cache strategy, retry pattern, timeout, helper methods and enhanced types written in tiny TypeScript, ES module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fetch",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"url": "https://github.com/AliMD/alwatr/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@alwatr/logger": "^0.
|
|
37
|
+
"@alwatr/logger": "^0.22.0",
|
|
38
38
|
"tslib": "^2.4.1"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "2c45f39d4f1d684c9580ed28501b31b7c170ebd4"
|
|
41
41
|
}
|