qmwts 1.1.71 → 1.1.73

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.
@@ -30,5 +30,6 @@ declare const _default: {
30
30
  * @param override 遇到重复元素是否覆盖
31
31
  */
32
32
  uniqueBy<T>(array: T[] | undefined, keyName: string, override?: boolean): T[];
33
+ sort<T>(array: T[], order: "asc" | "desc", ...values: ((item: T) => number)[]): void;
33
34
  };
34
35
  export default _default;
@@ -98,5 +98,19 @@ exports.default = {
98
98
  map.set(key, e);
99
99
  }
100
100
  return Array.from(map.values());
101
+ },
102
+ sort(array, order, ...values) {
103
+ if (!array || array.length === 0 || values.length === 0)
104
+ return;
105
+ const multiplier = order === 'asc' ? 1 : -1;
106
+ array.sort((a, b) => {
107
+ for (const fn of values) {
108
+ const valueA = fn(a);
109
+ const valueB = fn(b);
110
+ if (valueA !== valueB)
111
+ return (valueA - valueB) * multiplier;
112
+ }
113
+ return 0;
114
+ });
101
115
  }
102
116
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prototype_utils_1 = require("./prototype-utils");
4
+ const number_utils_1 = require("./number-utils");
4
5
  exports.default = {
5
6
  optionalChaining(o = {}, chain, substitute = '') {
6
7
  const chaining = chain.split('.');
@@ -48,7 +49,8 @@ exports.default = {
48
49
  return this.contains(valueA, valueB);
49
50
  if (prototype_utils_1.default.isArray(valueA) && prototype_utils_1.default.isArray(valueB))
50
51
  return this.contains(valueA, valueB);
51
- // 其他情况直接比较(包括 null、数字、字符串、布尔值等)
52
+ if (number_utils_1.default.isNumber(valueA) && number_utils_1.default.isNumber(valueB)) // 字符串数字和纯数字全部转为数字进行对比 '1' === 1
53
+ return +valueA === +valueB;
52
54
  return valueA === valueB;
53
55
  });
54
56
  }
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
- build(data: any | undefined, params: FormData | URLSearchParams): FormData | URLSearchParams;
3
- buildParams(data?: any): FormData | URLSearchParams;
4
- buildData(data?: any): FormData | URLSearchParams;
2
+ build<T extends FormData | URLSearchParams>(data: any | undefined, params: T): T;
3
+ buildParams(data?: any): URLSearchParams;
4
+ buildData(data?: any): FormData;
5
5
  };
6
6
  export default _default;
@@ -6,12 +6,9 @@ exports.default = {
6
6
  if (Array.isArray(value))
7
7
  for (const i of value)
8
8
  params.append(key, i);
9
- else if (isValidValue(value))
9
+ else if (value != null)
10
10
  params.append(key, value);
11
11
  }
12
12
  return params;
13
13
  }
14
14
  };
15
- function isValidValue(value) {
16
- return value !== null && value !== void 0;
17
- }
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ uuid(): string;
3
+ };
4
+ export default _default;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ uuid: function () {
5
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
6
+ var r = (Math.random() * 16) | 0;
7
+ var v = c === 'x' ? r : (r & 0x3) | 0x8;
8
+ return v.toString(16);
9
+ });
10
+ }
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qmwts",
3
- "version": "1.1.71",
3
+ "version": "1.1.73",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- import axios from 'axios';
2
- export default axios;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var axios_1 = require("axios");
4
- axios_1.default.interceptors.request.use(function (request) {
5
- console.log('request');
6
- return request;
7
- }, function (error) {
8
- console.log('request error');
9
- return Promise.reject(error);
10
- });
11
- axios_1.default.interceptors.response.use(function (response) {
12
- console.log('response');
13
- return response;
14
- }, function (error) {
15
- console.log('response error');
16
- return Promise.reject(error);
17
- });
18
- exports.default = axios_1.default;