@naturalcycles/js-lib 14.139.0 → 14.139.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/dist/http/fetcher.d.ts +0 -2
- package/dist/http/fetcher.js +5 -5
- package/dist/promise/pRetry.js +1 -1
- package/dist/seq/seq.js +0 -1
- package/dist-esm/http/fetcher.js +5 -5
- package/dist-esm/promise/pRetry.js +1 -1
- package/dist-esm/seq/seq.js +0 -1
- package/package.json +1 -1
- package/src/http/fetcher.ts +5 -5
- package/src/promise/pRetry.ts +1 -1
- package/src/seq/seq.ts +0 -2
package/dist/http/fetcher.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ import type { FetcherAfterResponseHook, FetcherBeforeRequestHook, FetcherBeforeR
|
|
|
3
3
|
/**
|
|
4
4
|
* Experimental wrapper around Fetch.
|
|
5
5
|
* Works in both Browser and Node, using `globalThis.fetch`.
|
|
6
|
-
*
|
|
7
|
-
* @experimental
|
|
8
6
|
*/
|
|
9
7
|
export declare class Fetcher {
|
|
10
8
|
private constructor();
|
package/dist/http/fetcher.js
CHANGED
|
@@ -20,8 +20,6 @@ const defRetryOptions = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Experimental wrapper around Fetch.
|
|
22
22
|
* Works in both Browser and Node, using `globalThis.fetch`.
|
|
23
|
-
*
|
|
24
|
-
* @experimental
|
|
25
23
|
*/
|
|
26
24
|
class Fetcher {
|
|
27
25
|
constructor(cfg = {}) {
|
|
@@ -121,7 +119,6 @@ class Fetcher {
|
|
|
121
119
|
},
|
|
122
120
|
signature,
|
|
123
121
|
};
|
|
124
|
-
/* eslint-disable no-await-in-loop */
|
|
125
122
|
while (!res.retryStatus.retryStopped) {
|
|
126
123
|
const started = Date.now();
|
|
127
124
|
if (this.cfg.logRequest) {
|
|
@@ -141,6 +138,8 @@ class Fetcher {
|
|
|
141
138
|
// For example, CORS error would result in "TypeError: failed to fetch" here
|
|
142
139
|
res.err = err;
|
|
143
140
|
res.ok = false;
|
|
141
|
+
// important to set it to undefined, otherwise it can keep the previous value (from previous try)
|
|
142
|
+
res.fetchResponse = undefined;
|
|
144
143
|
}
|
|
145
144
|
res.statusFamily = this.getStatusFamily(res);
|
|
146
145
|
if (res.fetchResponse?.ok) {
|
|
@@ -340,7 +339,8 @@ class Fetcher {
|
|
|
340
339
|
retryPost: false,
|
|
341
340
|
retry4xx: false,
|
|
342
341
|
retry5xx: true,
|
|
343
|
-
logger: console,
|
|
342
|
+
// logger: console, Danger! doing this mutates console!
|
|
343
|
+
logger: cfg.logger || console,
|
|
344
344
|
debug,
|
|
345
345
|
logRequest: debug,
|
|
346
346
|
logRequestBody: debug,
|
|
@@ -355,7 +355,7 @@ class Fetcher {
|
|
|
355
355
|
credentials: cfg.credentials,
|
|
356
356
|
},
|
|
357
357
|
hooks: {},
|
|
358
|
-
}, (0, object_util_1._omit)(cfg, ['method', 'credentials', 'headers']));
|
|
358
|
+
}, (0, object_util_1._omit)(cfg, ['method', 'credentials', 'headers', 'logger']));
|
|
359
359
|
norm.init.headers = (0, object_util_1._mapKeys)(norm.init.headers, k => k.toLowerCase());
|
|
360
360
|
return norm;
|
|
361
361
|
}
|
package/dist/promise/pRetry.js
CHANGED
|
@@ -25,7 +25,7 @@ async function pRetry(fn, opt = {}) {
|
|
|
25
25
|
const fname = name || fn.name || 'pRetry function';
|
|
26
26
|
let delay = initialDelay;
|
|
27
27
|
let attempt = 0;
|
|
28
|
-
/* eslint-disable no-
|
|
28
|
+
/* eslint-disable no-constant-condition */
|
|
29
29
|
while (true) {
|
|
30
30
|
const started = Date.now();
|
|
31
31
|
try {
|
package/dist/seq/seq.js
CHANGED
package/dist-esm/http/fetcher.js
CHANGED
|
@@ -18,8 +18,6 @@ const defRetryOptions = {
|
|
|
18
18
|
/**
|
|
19
19
|
* Experimental wrapper around Fetch.
|
|
20
20
|
* Works in both Browser and Node, using `globalThis.fetch`.
|
|
21
|
-
*
|
|
22
|
-
* @experimental
|
|
23
21
|
*/
|
|
24
22
|
export class Fetcher {
|
|
25
23
|
constructor(cfg = {}) {
|
|
@@ -129,7 +127,6 @@ export class Fetcher {
|
|
|
129
127
|
},
|
|
130
128
|
signature,
|
|
131
129
|
};
|
|
132
|
-
/* eslint-disable no-await-in-loop */
|
|
133
130
|
while (!res.retryStatus.retryStopped) {
|
|
134
131
|
const started = Date.now();
|
|
135
132
|
if (this.cfg.logRequest) {
|
|
@@ -149,6 +146,8 @@ export class Fetcher {
|
|
|
149
146
|
// For example, CORS error would result in "TypeError: failed to fetch" here
|
|
150
147
|
res.err = err;
|
|
151
148
|
res.ok = false;
|
|
149
|
+
// important to set it to undefined, otherwise it can keep the previous value (from previous try)
|
|
150
|
+
res.fetchResponse = undefined;
|
|
152
151
|
}
|
|
153
152
|
res.statusFamily = this.getStatusFamily(res);
|
|
154
153
|
if ((_g = res.fetchResponse) === null || _g === void 0 ? void 0 : _g.ok) {
|
|
@@ -382,7 +381,8 @@ export class Fetcher {
|
|
|
382
381
|
retryPost: false,
|
|
383
382
|
retry4xx: false,
|
|
384
383
|
retry5xx: true,
|
|
385
|
-
logger: console,
|
|
384
|
+
// logger: console, Danger! doing this mutates console!
|
|
385
|
+
logger: cfg.logger || console,
|
|
386
386
|
debug,
|
|
387
387
|
logRequest: debug,
|
|
388
388
|
logRequestBody: debug,
|
|
@@ -397,7 +397,7 @@ export class Fetcher {
|
|
|
397
397
|
credentials: cfg.credentials,
|
|
398
398
|
},
|
|
399
399
|
hooks: {},
|
|
400
|
-
}, _omit(cfg, ['method', 'credentials', 'headers']));
|
|
400
|
+
}, _omit(cfg, ['method', 'credentials', 'headers', 'logger']));
|
|
401
401
|
norm.init.headers = _mapKeys(norm.init.headers, k => k.toLowerCase());
|
|
402
402
|
return norm;
|
|
403
403
|
}
|
|
@@ -21,7 +21,7 @@ export async function pRetry(fn, opt = {}) {
|
|
|
21
21
|
const fname = name || fn.name || 'pRetry function';
|
|
22
22
|
let delay = initialDelay;
|
|
23
23
|
let attempt = 0;
|
|
24
|
-
/* eslint-disable no-
|
|
24
|
+
/* eslint-disable no-constant-condition */
|
|
25
25
|
while (true) {
|
|
26
26
|
const started = Date.now();
|
|
27
27
|
try {
|
package/dist-esm/seq/seq.js
CHANGED
package/package.json
CHANGED
package/src/http/fetcher.ts
CHANGED
|
@@ -39,8 +39,6 @@ const defRetryOptions: FetcherRetryOptions = {
|
|
|
39
39
|
/**
|
|
40
40
|
* Experimental wrapper around Fetch.
|
|
41
41
|
* Works in both Browser and Node, using `globalThis.fetch`.
|
|
42
|
-
*
|
|
43
|
-
* @experimental
|
|
44
42
|
*/
|
|
45
43
|
export class Fetcher {
|
|
46
44
|
private constructor(cfg: FetcherCfg & FetcherOptions = {}) {
|
|
@@ -184,7 +182,6 @@ export class Fetcher {
|
|
|
184
182
|
signature,
|
|
185
183
|
} as FetcherResponse<any>
|
|
186
184
|
|
|
187
|
-
/* eslint-disable no-await-in-loop */
|
|
188
185
|
while (!res.retryStatus.retryStopped) {
|
|
189
186
|
const started = Date.now()
|
|
190
187
|
|
|
@@ -207,6 +204,8 @@ export class Fetcher {
|
|
|
207
204
|
// For example, CORS error would result in "TypeError: failed to fetch" here
|
|
208
205
|
res.err = err as Error
|
|
209
206
|
res.ok = false
|
|
207
|
+
// important to set it to undefined, otherwise it can keep the previous value (from previous try)
|
|
208
|
+
res.fetchResponse = undefined
|
|
210
209
|
}
|
|
211
210
|
res.statusFamily = this.getStatusFamily(res)
|
|
212
211
|
|
|
@@ -435,7 +434,8 @@ export class Fetcher {
|
|
|
435
434
|
retryPost: false,
|
|
436
435
|
retry4xx: false,
|
|
437
436
|
retry5xx: true,
|
|
438
|
-
logger: console,
|
|
437
|
+
// logger: console, Danger! doing this mutates console!
|
|
438
|
+
logger: cfg.logger || console,
|
|
439
439
|
debug,
|
|
440
440
|
logRequest: debug,
|
|
441
441
|
logRequestBody: debug,
|
|
@@ -451,7 +451,7 @@ export class Fetcher {
|
|
|
451
451
|
},
|
|
452
452
|
hooks: {},
|
|
453
453
|
},
|
|
454
|
-
_omit(cfg, ['method', 'credentials', 'headers']),
|
|
454
|
+
_omit(cfg, ['method', 'credentials', 'headers', 'logger']),
|
|
455
455
|
)
|
|
456
456
|
|
|
457
457
|
norm.init.headers = _mapKeys(norm.init.headers, k => k.toLowerCase())
|
package/src/promise/pRetry.ts
CHANGED
package/src/seq/seq.ts
CHANGED