@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.
@@ -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 "./UtilsWindowApi";
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[] | NodeList>(data: T, getPropertyValueFunc: string | ((value: T) => any), sortByDesc?: boolean): T;
1364
+ sortListByProperty<T extends any>(data: T[], getPropertyValueFunc: string | ((value: T) => any), sortByDesc?: boolean): T[];
1365
1365
  /**
1366
1366
  * 字符串转正则,用于把字符串中不规范的字符进行转义
1367
1367
  * @param targetString 需要进行转换的字符串
@@ -8,7 +8,7 @@ export type UtilsWindowApiOption = {
8
8
  self: Window & typeof globalThis;
9
9
  top: Window;
10
10
  };
11
- export declare class UtilsWindowApi {
11
+ export declare class WindowApi {
12
12
  /** 默认的配置 */
13
13
  private defaultApi;
14
14
  /** 使用的配置 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
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 { UtilsWindowApi, type UtilsWindowApiOption } from "./UtilsWindowApi";
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: UtilsWindowApi;
50
+ private windowApi: WindowApi;
51
51
  constructor(option?: UtilsWindowApiOption) {
52
- this.windowApi = new UtilsWindowApi(option);
52
+ this.windowApi = new WindowApi(option);
53
53
  }
54
54
  /** 版本号 */
55
- version = "2024.7.20";
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[] | NodeList>(
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[] | NodeList>(
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 (data instanceof NodeList || UtilsContext.isJQuery(data)) {
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 {
@@ -9,7 +9,7 @@ export type UtilsWindowApiOption = {
9
9
  top: Window;
10
10
  };
11
11
 
12
- export class UtilsWindowApi {
12
+ export class WindowApi {
13
13
  /** 默认的配置 */
14
14
  private defaultApi: UtilsWindowApiOption = {
15
15
  document: document,