keq 2.6.0 → 2.6.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/CHANGELOG.md +14 -0
- package/dist/esm/src/middlewares/fetch-arguments-middleware.js +8 -1
- package/dist/esm/src/middlewares/retry-middleware.js +5 -4
- package/dist/umd/src/middlewares/fetch-arguments-middleware.js +8 -1
- package/dist/umd/src/middlewares/retry-middleware.js +5 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [2.6.2](https://github.com/keq-request/keq/compare/v2.6.1...v2.6.2) (2024-05-29)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* retryDelay option setting is invaild ([9bc07f8](https://github.com/keq-request/keq/commit/9bc07f8c1d870c51f1c1013dd12e038e278884e3))
|
|
11
|
+
|
|
12
|
+
## [2.6.1](https://github.com/keq-request/keq/compare/v2.6.0...v2.6.1) (2024-05-28)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* body should not be set when undefined ([0674870](https://github.com/keq-request/keq/commit/0674870e3adade4f7c5e7e8209322d52b501b8ce))
|
|
18
|
+
|
|
5
19
|
## [2.6.0](https://github.com/keq-request/keq/compare/v2.5.5...v2.6.0) (2024-05-28)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -65,7 +65,14 @@ function compileBody(ctx) {
|
|
|
65
65
|
}
|
|
66
66
|
if (body instanceof Buffer)
|
|
67
67
|
return body;
|
|
68
|
-
|
|
68
|
+
if (body === undefined)
|
|
69
|
+
return body;
|
|
70
|
+
if (body === null)
|
|
71
|
+
return 'null';
|
|
72
|
+
if (typeof body === 'string')
|
|
73
|
+
return body;
|
|
74
|
+
if (typeof body === 'number')
|
|
75
|
+
return String(body);
|
|
69
76
|
}
|
|
70
77
|
export function fetchArgumentsMiddleware() {
|
|
71
78
|
return async function fetchArgumentsMiddleware(ctx, next) {
|
|
@@ -7,12 +7,13 @@ export function retryMiddleware() {
|
|
|
7
7
|
const retryTimes = Number.isInteger(ctx.options.retryTimes)
|
|
8
8
|
? ctx.options.retryTimes + 1
|
|
9
9
|
: 1;
|
|
10
|
+
const delayOptions = ctx.options.retryDelay;
|
|
10
11
|
const retryDelay = async (attempt, error, ctx) => {
|
|
11
|
-
if (typeof
|
|
12
|
-
return
|
|
12
|
+
if (typeof delayOptions === 'function') {
|
|
13
|
+
return delayOptions(attempt, error, ctx);
|
|
13
14
|
}
|
|
14
|
-
else if (typeof
|
|
15
|
-
return
|
|
15
|
+
else if (typeof delayOptions === 'number') {
|
|
16
|
+
return delayOptions;
|
|
16
17
|
}
|
|
17
18
|
return 0;
|
|
18
19
|
};
|
|
@@ -77,7 +77,14 @@
|
|
|
77
77
|
}
|
|
78
78
|
if (body instanceof Buffer)
|
|
79
79
|
return body;
|
|
80
|
-
|
|
80
|
+
if (body === undefined)
|
|
81
|
+
return body;
|
|
82
|
+
if (body === null)
|
|
83
|
+
return 'null';
|
|
84
|
+
if (typeof body === 'string')
|
|
85
|
+
return body;
|
|
86
|
+
if (typeof body === 'number')
|
|
87
|
+
return String(body);
|
|
81
88
|
}
|
|
82
89
|
function fetchArgumentsMiddleware() {
|
|
83
90
|
return async function fetchArgumentsMiddleware(ctx, next) {
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
const retryTimes = Number.isInteger(ctx.options.retryTimes)
|
|
20
20
|
? ctx.options.retryTimes + 1
|
|
21
21
|
: 1;
|
|
22
|
+
const delayOptions = ctx.options.retryDelay;
|
|
22
23
|
const retryDelay = async (attempt, error, ctx) => {
|
|
23
|
-
if (typeof
|
|
24
|
-
return
|
|
24
|
+
if (typeof delayOptions === 'function') {
|
|
25
|
+
return delayOptions(attempt, error, ctx);
|
|
25
26
|
}
|
|
26
|
-
else if (typeof
|
|
27
|
-
return
|
|
27
|
+
else if (typeof delayOptions === 'number') {
|
|
28
|
+
return delayOptions;
|
|
28
29
|
}
|
|
29
30
|
return 0;
|
|
30
31
|
};
|