@whitesev/utils 2.1.0 → 2.1.1
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 +5 -4
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +5 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +5 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +5 -4
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +5 -4
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +5 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Utils.d.ts +2 -2
- package/dist/types/src/{UtilsWindowApi.d.ts → WindowApi.d.ts} +1 -1
- package/package.json +1 -1
- package/src/Utils.ts +14 -11
- package/src/{UtilsWindowApi.ts → WindowApi.ts} +1 -1
|
@@ -12,7 +12,7 @@ import { UtilsDictionary } from "./Dictionary";
|
|
|
12
12
|
import type { DOMUtils_EventType } from "./Event";
|
|
13
13
|
import type { Vue2Object } from "./VueObject";
|
|
14
14
|
import type { UtilsAjaxHookResult } from "./AjaxHookerType";
|
|
15
|
-
import { type UtilsWindowApiOption } from "./
|
|
15
|
+
import { type UtilsWindowApiOption } from "./WindowApi";
|
|
16
16
|
export declare var unsafeWindow: Window & typeof globalThis;
|
|
17
17
|
export type JSTypeMap = {
|
|
18
18
|
string: string;
|
|
@@ -1361,7 +1361,7 @@ declare class Utils {
|
|
|
1361
1361
|
* Utils.sortListByProperty([{"time":"2022-1-1"},{"time":"2022-2-2"}],(item)=>{return item["time"]},false)
|
|
1362
1362
|
* > [{time: '2022-1-1'},{time: '2022-2-2'}]
|
|
1363
1363
|
**/
|
|
1364
|
-
sortListByProperty<T extends any
|
|
1364
|
+
sortListByProperty<T extends any>(data: T[], getPropertyValueFunc: string | ((value: T) => any), sortByDesc?: boolean): T[];
|
|
1365
1365
|
/**
|
|
1366
1366
|
* 字符串转正则,用于把字符串中不规范的字符进行转义
|
|
1367
1367
|
* @param targetString 需要进行转换的字符串
|
package/package.json
CHANGED
package/src/Utils.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type { DOMUtils_EventType } from "./Event";
|
|
|
15
15
|
import type { Vue2Object } from "./VueObject";
|
|
16
16
|
import type { UtilsAjaxHookResult } from "./AjaxHookerType";
|
|
17
17
|
import { GenerateUUID } from "./UtilsCommon";
|
|
18
|
-
import {
|
|
18
|
+
import { WindowApi, type UtilsWindowApiOption } from "./WindowApi";
|
|
19
19
|
|
|
20
20
|
export declare var unsafeWindow: Window & typeof globalThis;
|
|
21
21
|
|
|
@@ -47,12 +47,12 @@ export declare interface AnyObject {
|
|
|
47
47
|
export declare interface Vue2Context extends Vue2Object {}
|
|
48
48
|
|
|
49
49
|
class Utils {
|
|
50
|
-
private windowApi:
|
|
50
|
+
private windowApi: WindowApi;
|
|
51
51
|
constructor(option?: UtilsWindowApiOption) {
|
|
52
|
-
this.windowApi = new
|
|
52
|
+
this.windowApi = new WindowApi(option);
|
|
53
53
|
}
|
|
54
54
|
/** 版本号 */
|
|
55
|
-
version = "2024.7.
|
|
55
|
+
version = "2024.7.24";
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
|
|
@@ -3602,16 +3602,16 @@ class Utils {
|
|
|
3602
3602
|
* Utils.sortListByProperty([{"time":"2022-1-1"},{"time":"2022-2-2"}],(item)=>{return item["time"]},false)
|
|
3603
3603
|
* > [{time: '2022-1-1'},{time: '2022-2-2'}]
|
|
3604
3604
|
**/
|
|
3605
|
-
sortListByProperty<T extends any
|
|
3606
|
-
data: T,
|
|
3605
|
+
sortListByProperty<T extends any>(
|
|
3606
|
+
data: T[],
|
|
3607
3607
|
getPropertyValueFunc: string | ((value: T) => any),
|
|
3608
3608
|
sortByDesc?: boolean
|
|
3609
|
-
): T;
|
|
3610
|
-
sortListByProperty<T extends any
|
|
3611
|
-
data: T,
|
|
3609
|
+
): T[];
|
|
3610
|
+
sortListByProperty<T extends any>(
|
|
3611
|
+
data: T[],
|
|
3612
3612
|
getPropertyValueFunc: string | ((value: T) => any),
|
|
3613
3613
|
sortByDesc: boolean = true
|
|
3614
|
-
): T {
|
|
3614
|
+
): T[] {
|
|
3615
3615
|
let UtilsContext = this;
|
|
3616
3616
|
if (
|
|
3617
3617
|
typeof getPropertyValueFunc !== "function" &&
|
|
@@ -3702,7 +3702,10 @@ class Utils {
|
|
|
3702
3702
|
}
|
|
3703
3703
|
if (Array.isArray(data)) {
|
|
3704
3704
|
data.sort(sortFunc);
|
|
3705
|
-
} else if (
|
|
3705
|
+
} else if (
|
|
3706
|
+
(data as any) instanceof NodeList ||
|
|
3707
|
+
UtilsContext.isJQuery(data)
|
|
3708
|
+
) {
|
|
3706
3709
|
sortNodeFunc(data as any, getDataFunc as any);
|
|
3707
3710
|
result = (getDataFunc as any)();
|
|
3708
3711
|
} else {
|