@whitesev/utils 1.5.1 → 1.5.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/index.amd.js.map +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Httpx.d.ts +2 -2
- package/package.json +1 -1
- package/src/Httpx.ts +3 -3
package/dist/src/Httpx.d.ts
CHANGED
|
@@ -1139,7 +1139,7 @@ declare class Httpx {
|
|
|
1139
1139
|
* 添加拦截器
|
|
1140
1140
|
* @param fn 设置的请求前回调函数,如果返回配置,则使用返回的配置,如果返回null|undefined,则阻止请求
|
|
1141
1141
|
*/
|
|
1142
|
-
use(fn: <T
|
|
1142
|
+
use(fn: <T extends Required<HttpxDetails>>(details: T) => void | T): string | undefined;
|
|
1143
1143
|
/**
|
|
1144
1144
|
* 移除拦截器
|
|
1145
1145
|
* @param id 通过use返回的id
|
|
@@ -1162,7 +1162,7 @@ declare class Httpx {
|
|
|
1162
1162
|
* @param errorFn 设置的响应后回调函数,如果返回响应,则使用返回的响应,如果返回null|undefined,则阻止响应
|
|
1163
1163
|
* + 超出 2xx 范围的状态码都会触发该函数
|
|
1164
1164
|
*/
|
|
1165
|
-
use(successFn?: (<T_1
|
|
1165
|
+
use(successFn?: (<T_1 extends HttpxAsyncResultData<HttpxDetails>>(response: HttpxAsyncResultData) => void | T_1) | undefined, errorFn?: (<T_2 extends HttpxHookErrorData>(data: T_2) => void | T_2) | undefined): string | undefined;
|
|
1166
1166
|
/**
|
|
1167
1167
|
* 移除拦截器
|
|
1168
1168
|
* @param id 通过use返回的id
|
package/package.json
CHANGED
package/src/Httpx.ts
CHANGED
|
@@ -2082,7 +2082,7 @@ class Httpx {
|
|
|
2082
2082
|
* 添加拦截器
|
|
2083
2083
|
* @param fn 设置的请求前回调函数,如果返回配置,则使用返回的配置,如果返回null|undefined,则阻止请求
|
|
2084
2084
|
*/
|
|
2085
|
-
use(fn: <T
|
|
2085
|
+
use(fn: <T extends Required<HttpxDetails>>(details: T) => void | T) {
|
|
2086
2086
|
if (typeof fn !== "function") {
|
|
2087
2087
|
console.warn("[Httpx-interceptors-request] 请传入拦截器函数");
|
|
2088
2088
|
return;
|
|
@@ -2116,10 +2116,10 @@ class Httpx {
|
|
|
2116
2116
|
* + 超出 2xx 范围的状态码都会触发该函数
|
|
2117
2117
|
*/
|
|
2118
2118
|
use(
|
|
2119
|
-
successFn?: <T
|
|
2119
|
+
successFn?: <T extends HttpxAsyncResultData>(
|
|
2120
2120
|
response: HttpxAsyncResultData
|
|
2121
2121
|
) => void | T,
|
|
2122
|
-
errorFn?: <T
|
|
2122
|
+
errorFn?: <T extends HttpxHookErrorData>(data: T) => void | T
|
|
2123
2123
|
) {
|
|
2124
2124
|
if (typeof successFn !== "function" && typeof errorFn !== "function") {
|
|
2125
2125
|
console.warn("[Httpx-interceptors-response] 必须传入一个拦截器函数");
|