qmwts 1.1.79 → 1.1.81
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,7 +30,7 @@ declare const _default: {
|
|
|
30
30
|
* @param override 遇到重复元素是否覆盖
|
|
31
31
|
*/
|
|
32
32
|
uniqueByKey<T, K = unknown>(array: T[] | undefined, value: (item: T) => K, override?: boolean): T[];
|
|
33
|
-
sort<T>(array: T[], order: "asc" | "desc", ...values: ((item: T) =>
|
|
33
|
+
sort<T>(array: T[], order: "asc" | "desc", ...values: ((item: T) => any)[]): void;
|
|
34
34
|
mergeByKey<T extends object>(keyExtractor: (item: T) => string | number | symbol, ...arrays: T[][]): T[];
|
|
35
35
|
};
|
|
36
36
|
export default _default;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const lodash_es_1 = require("lodash-es");
|
|
4
|
+
const number_utils_1 = require("./number-utils");
|
|
4
5
|
exports.default = {
|
|
5
6
|
/**
|
|
6
7
|
* 数组转化为树形结构
|
|
@@ -112,8 +113,15 @@ exports.default = {
|
|
|
112
113
|
for (const fn of values) {
|
|
113
114
|
const valueA = fn(a);
|
|
114
115
|
const valueB = fn(b);
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
let result = 0;
|
|
117
|
+
if (number_utils_1.default.isNumber(valueA) && number_utils_1.default.isNumber(valueB)) {
|
|
118
|
+
result = valueA - valueB;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
result = String(valueA).localeCompare(String(valueB));
|
|
122
|
+
}
|
|
123
|
+
if (result !== 0)
|
|
124
|
+
return result * multiplier;
|
|
117
125
|
}
|
|
118
126
|
return 0;
|
|
119
127
|
});
|