@anjianshi/utils 3.3.0 → 3.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anjianshi/utils",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Common JavaScript Utils",
5
5
  "homepage": "https://github.com/anjianshi/js-packages/utils",
6
6
  "bugs": {
@@ -31,12 +31,12 @@
31
31
  "redis": "^5.5.6",
32
32
  "typescript": "^5.8.3",
33
33
  "vconsole": "^3.15.1",
34
+ "@anjianshi/presets-eslint-base": "6.0.0",
34
35
  "@anjianshi/presets-eslint-node": "6.0.0",
35
- "@anjianshi/presets-prettier": "3.0.5",
36
36
  "@anjianshi/presets-eslint-typescript": "6.0.0",
37
- "@anjianshi/presets-typescript": "3.2.5",
38
37
  "@anjianshi/presets-eslint-react": "6.0.0",
39
- "@anjianshi/presets-eslint-base": "6.0.0"
38
+ "@anjianshi/presets-prettier": "3.0.5",
39
+ "@anjianshi/presets-typescript": "3.2.5"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@emotion/react": "^11.14.0",
package/request/client.js CHANGED
@@ -38,7 +38,7 @@ export class BaseRequestClient {
38
38
  }
39
39
  catch (error) {
40
40
  // 失败情形“手动取消”
41
- if (manualSignal && manualSignal.aborted && manualSignal.reason === error) {
41
+ if (manualSignal?.aborted && manualSignal.reason === error) {
42
42
  const reason = error instanceof DOMException && error.name === 'AbortError' ? null : error;
43
43
  return this.handleError(failed('Request Aborted', 'RequestAborted', { options, reason }));
44
44
  }
@@ -99,7 +99,7 @@ export class BaseRequestClient {
99
99
  // -------------------------------
100
100
  async formatOptions(input) {
101
101
  const predefined = this.prefefinedOptions;
102
- const { urlPrefix = predefined.urlPrefix ?? '', url: rawUrl, query = {}, method = predefined.method ?? 'GET', headers: rawHeaders = {}, body: rawBody = null, data, timeout = predefined.timeout ?? 0, binary = false, signal, } = input;
102
+ const { urlPrefix = predefined.urlPrefix ?? '', url: rawUrl, query = {}, method = predefined.method ?? 'GET', headers: rawHeaders = {}, body: rawBody = null, data, timeout = predefined.timeout ?? 0, binary = false, signal, format, } = input;
103
103
  const headers = {
104
104
  ...(predefined.headers ?? {}),
105
105
  ...rawHeaders,
@@ -123,6 +123,7 @@ export class BaseRequestClient {
123
123
  timeout,
124
124
  binary,
125
125
  signal,
126
+ format,
126
127
  };
127
128
  Object.assign(options.headers, await this.getHeaders(options, input));
128
129
  return options;
@@ -20,7 +20,7 @@ export interface Options {
20
20
  /** 可通过此信号手动终止请求 */
21
21
  signal?: AbortSignal;
22
22
  /** 对请求成功时得到的数据进行最终格式化 */
23
- format?: <RawT, FormattedT>(responseData: RawT) => FormattedT;
23
+ format?: (responseData: any) => any;
24
24
  }
25
25
  /** 可预指定的请求参数 */
26
26
  export type PredefinedOptions = Pick<Options, 'urlPrefix' | 'method' | 'headers' | 'timeout'>;