@gct-paas/core 0.0.1-dev.6 → 0.0.1-dev.8

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.
Files changed (124) hide show
  1. package/dist/index.min.cjs +1 -1
  2. package/dist/index.system.min.js +1 -1
  3. package/es/_virtual/_commonjsHelpers.mjs +40 -0
  4. package/es/_virtual/index.mjs +7 -0
  5. package/es/constants/index.d.ts +5 -1
  6. package/es/constants/index.mjs +3 -2
  7. package/es/enums/app-designer/index.d.ts +80 -0
  8. package/es/enums/app-designer/index.mjs +58 -0
  9. package/es/enums/appEnum.d.ts +605 -0
  10. package/es/enums/appEnum.mjs +356 -0
  11. package/es/enums/appStateEnum.d.ts +14 -0
  12. package/es/enums/appStateEnum.mjs +12 -0
  13. package/es/enums/authActionEnum.d.ts +50 -0
  14. package/es/enums/authActionEnum.mjs +55 -0
  15. package/es/enums/breakpointEnum.d.ts +18 -0
  16. package/es/enums/breakpointEnum.mjs +28 -0
  17. package/es/enums/cacheEnum.d.ts +19 -0
  18. package/es/enums/cacheEnum.mjs +23 -0
  19. package/es/enums/designEnum.d.ts +82 -0
  20. package/es/enums/designEnum.mjs +72 -0
  21. package/es/enums/exceptionEnum.d.ts +17 -0
  22. package/es/enums/exceptionEnum.mjs +19 -0
  23. package/es/enums/httpEnum.d.ts +65 -0
  24. package/es/enums/httpEnum.mjs +63 -0
  25. package/es/enums/index.d.ts +16 -0
  26. package/es/enums/index.mjs +22 -0
  27. package/es/enums/menuEnum.d.ts +35 -0
  28. package/es/enums/menuEnum.mjs +40 -0
  29. package/es/enums/page-designer/designer.d.ts +277 -0
  30. package/es/enums/page-designer/designer.mjs +330 -0
  31. package/es/enums/page-designer/index.d.ts +4 -0
  32. package/es/enums/page-designer/index.mjs +6 -0
  33. package/es/enums/page-designer/panel.d.ts +243 -0
  34. package/es/enums/page-designer/panel.mjs +195 -0
  35. package/es/enums/page-designer/toolkit.d.ts +10 -0
  36. package/es/enums/page-designer/toolkit.mjs +14 -0
  37. package/es/enums/page-designer/widget.d.ts +316 -0
  38. package/es/enums/page-designer/widget.mjs +335 -0
  39. package/es/enums/pageEnum.d.ts +11 -0
  40. package/es/enums/pageEnum.mjs +15 -0
  41. package/es/enums/plugin-enum.d.ts +20 -0
  42. package/es/enums/plugin-enum.mjs +9 -0
  43. package/es/enums/processEnum.d.ts +35 -0
  44. package/es/enums/processEnum.mjs +28 -0
  45. package/es/enums/roleEnum.d.ts +4 -0
  46. package/es/enums/roleEnum.mjs +8 -0
  47. package/es/enums/sizeEnum.d.ts +5 -0
  48. package/es/enums/sizeEnum.mjs +9 -0
  49. package/es/global/gct/gct.d.ts +47 -0
  50. package/es/global/gct/gct.mjs +49 -0
  51. package/es/global/index.d.ts +1 -0
  52. package/es/global/index.mjs +3 -0
  53. package/es/index.d.ts +14 -0
  54. package/es/index.mjs +43 -1
  55. package/es/interface/controller/i-designer-controller.d.ts +116 -0
  56. package/es/interface/controller/i-designer-controller.mjs +1 -0
  57. package/es/interface/controller/index.d.ts +1 -0
  58. package/es/interface/controller/index.mjs +1 -0
  59. package/es/interface/hooks/i-designer-hooks.d.ts +26 -0
  60. package/es/interface/hooks/i-designer-hooks.mjs +3 -0
  61. package/es/interface/hooks/index.d.ts +1 -0
  62. package/es/interface/hooks/index.mjs +1 -0
  63. package/es/interface/i-import-style-map/i-import-style-map.d.ts +15 -0
  64. package/es/interface/i-import-style-map/i-import-style-map.mjs +1 -0
  65. package/es/interface/i-pinia-action/i-global-actions.d.ts +14 -0
  66. package/es/interface/i-pinia-action/i-global-actions.mjs +1 -0
  67. package/es/interface/i-pinia-getter/i-global-getters.d.ts +16 -0
  68. package/es/interface/i-pinia-getter/i-global-getters.mjs +1 -0
  69. package/es/interface/i-pinia-state/i-global-state.d.ts +15 -0
  70. package/es/interface/i-pinia-state/i-global-state.mjs +1 -0
  71. package/es/interface/index.d.ts +8 -0
  72. package/es/interface/index.mjs +6 -0
  73. package/es/interface/low-code-types/index.d.ts +4 -0
  74. package/es/interface/low-code-types/index.mjs +5 -0
  75. package/es/interface/low-code-types/modal-types.d.ts +67 -0
  76. package/es/interface/low-code-types/modal-types.mjs +3 -0
  77. package/es/interface/low-code-types/model/index.d.ts +5338 -0
  78. package/es/interface/low-code-types/model/index.mjs +1 -0
  79. package/es/interface/low-code-types/schema/index.d.ts +12 -0
  80. package/es/interface/low-code-types/schema/index.mjs +1 -0
  81. package/es/interface/low-code-types/widget-basic-types.d.ts +655 -0
  82. package/es/interface/low-code-types/widget-basic-types.mjs +3 -0
  83. package/es/interface/state/i-designer-state.d.ts +39 -0
  84. package/es/interface/state/i-designer-state.mjs +1 -0
  85. package/es/interface/state/index.d.ts +1 -0
  86. package/es/interface/state/index.mjs +1 -0
  87. package/es/node_modules/.pnpm/path-browserify@1.0.1/node_modules/path-browserify/index.mjs +541 -0
  88. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/hook/async-series-hook/async-series-hook.mjs +73 -0
  89. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/hook/index.mjs +2 -0
  90. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/hook/sync-series-hook/sync-series-hook.mjs +100 -0
  91. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/index.mjs +2 -0
  92. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/utils/array/array.mjs +47 -0
  93. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/utils/index.mjs +5 -0
  94. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/utils/object/object.mjs +24 -0
  95. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/utils/qx-event/qx-event.mjs +94 -0
  96. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/utils/qx-event-emitter/qx-event-emitter.mjs +146 -0
  97. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/utils/type-util/type-util.mjs +149 -0
  98. package/es/node_modules/.pnpm/qx-util@0.4.8/node_modules/qx-util/out/utils/util/util.mjs +227 -0
  99. package/es/provider/i-designer-provider/i-designer-provider.d.ts +102 -0
  100. package/es/provider/i-designer-provider/i-designer-provider.mjs +1 -0
  101. package/es/provider/index.d.ts +1 -0
  102. package/es/provider/index.mjs +1 -0
  103. package/es/register/designer-register/designer-register.d.ts +58 -0
  104. package/es/register/designer-register/designer-register.mjs +70 -0
  105. package/es/register/index.d.ts +2 -0
  106. package/es/register/index.mjs +4 -0
  107. package/es/register/render-register/render-register.d.ts +59 -0
  108. package/es/register/render-register/render-register.mjs +65 -0
  109. package/es/state/global-pinia-state/global-pinia-state.d.ts +16 -0
  110. package/es/state/global-pinia-state/global-pinia-state.mjs +11 -0
  111. package/es/state/index.d.ts +1 -0
  112. package/es/state/index.mjs +3 -0
  113. package/es/store/global-store.d.ts +2 -0
  114. package/es/store/global-store.mjs +22 -0
  115. package/es/store/index.d.ts +20 -0
  116. package/es/store/index.mjs +21 -0
  117. package/es/types/index.d.ts +46 -0
  118. package/es/utils/index.d.ts +2 -0
  119. package/es/utils/index.mjs +2 -0
  120. package/es/utils/plugin-pkg-util/plugin-pkg-util.d.ts +86 -0
  121. package/es/utils/plugin-pkg-util/plugin-pkg-util.mjs +164 -0
  122. package/es/utils/plugin-static-resource/plugin-static-resource.d.ts +41 -0
  123. package/es/utils/plugin-static-resource/plugin-static-resource.mjs +46 -0
  124. package/package.json +14 -6
@@ -0,0 +1,100 @@
1
+ import '../../utils/index.mjs';
2
+ import { isFunc } from '../../utils/type-util/type-util.mjs';
3
+
4
+ /**
5
+ * 串联钩子,按照注册顺序执行
6
+ *
7
+ * @export
8
+ * @class SyncSeriesHook
9
+ * @template T 输入值类型
10
+ * @template C 上下文声明对象
11
+ */
12
+ class SyncSeriesHook {
13
+ constructor() {
14
+ /**
15
+ * 已注册的钩子回调
16
+ *
17
+ * @protected
18
+ * @type {IHookCallItem[]}
19
+ * @memberof SyncSeriesHook
20
+ */
21
+ this.items = [];
22
+ }
23
+ /**
24
+ * 当前注册钩子个数
25
+ *
26
+ * @author chitanda
27
+ * @date 2021-04-30 14:04:43
28
+ * @readonly
29
+ * @type {number}
30
+ */
31
+ get size() {
32
+ return this.items.length;
33
+ }
34
+ /**
35
+ * 触发钩子,当某个钩子返回「null」时,中断后续执行。
36
+ *
37
+ * @param {C} context
38
+ * @param {...AsArray<T>} args
39
+ * @return {*} {C}
40
+ * @memberof SyncSeriesHook
41
+ */
42
+ callSync(context, ...args) {
43
+ const _context = context || Object.create({});
44
+ let bol;
45
+ for (let i = 0; i < this.items.length; i++) {
46
+ const item = this.items[i];
47
+ if (item.fn) {
48
+ bol = item.fn(_context, ...args);
49
+ }
50
+ if (bol === null) {
51
+ console.warn(`因${item.fn ? item.fn.name : null}方法返回值为「null」,钩子中断执行。`, item);
52
+ break;
53
+ }
54
+ }
55
+ return _context;
56
+ }
57
+ /**
58
+ * 注册钩子
59
+ *
60
+ * @param {((...args: AsArray<T>) => void)} fn 回调
61
+ * @memberof SyncSeriesHook
62
+ */
63
+ tap(fn) {
64
+ if (fn && isFunc(fn)) {
65
+ const opt = {
66
+ mode: 'sync',
67
+ };
68
+ opt.fn = fn;
69
+ this.items.push(opt);
70
+ }
71
+ }
72
+ /**
73
+ * 删除钩子注册
74
+ *
75
+ * @author chitanda
76
+ * @date 2021-04-30 14:04:31
77
+ * @param {(context: C, ...args: AsArray<T>) => void} callBack
78
+ */
79
+ removeTap(callBack) {
80
+ if (callBack) {
81
+ for (let i = 0; i < this.items.length; i++) {
82
+ const item = this.items[i];
83
+ if (callBack === item.fn) {
84
+ this.items.splice(i, 1);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ /**
90
+ * 释放已注册的钩子
91
+ *
92
+ * @author chitanda
93
+ * @date 2022-08-15 22:08:44
94
+ */
95
+ clear() {
96
+ this.items = [];
97
+ }
98
+ }
99
+
100
+ export { SyncSeriesHook };
@@ -0,0 +1,2 @@
1
+ import './utils/index.mjs';
2
+ import './hook/index.mjs';
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 正序排序
3
+ *
4
+ * @export
5
+ * @param {any[]} list 需要排序的数据
6
+ * @param {string} [sortField] 排序字段,无排序字段对比本身
7
+ * @return {*} {any[]}
8
+ */
9
+ function ascSort(list, sortField) {
10
+ return list.sort((a, b) => {
11
+ const v1 = sortField ? a[sortField] : a;
12
+ const v2 = sortField ? b[sortField] : b;
13
+ if (v1 > v2) {
14
+ return 1;
15
+ }
16
+ if (v1 < v2) {
17
+ return -1;
18
+ }
19
+ return 0;
20
+ });
21
+ }
22
+ /**
23
+ * 倒叙排序
24
+ *
25
+ * @author chitanda
26
+ * @date 2022-08-30 14:08:10
27
+ * @export
28
+ * @template T
29
+ * @param {T[]} list 需要排序的数据
30
+ * @param {string} [sortField] 排序字段,无排序字段对比本身
31
+ * @return {*} {T[]}
32
+ */
33
+ function descSort(list, sortField) {
34
+ return list.sort((a, b) => {
35
+ const v1 = sortField ? a[sortField] : a;
36
+ const v2 = sortField ? b[sortField] : b;
37
+ if (v1 < v2) {
38
+ return 1;
39
+ }
40
+ if (v1 > v2) {
41
+ return -1;
42
+ }
43
+ return 0;
44
+ });
45
+ }
46
+
47
+ export { ascSort, descSort };
@@ -0,0 +1,5 @@
1
+ export { ascSort, descSort } from './array/array.mjs';
2
+ export { clearAll } from './object/object.mjs';
3
+ export { QXEvent } from './qx-event/qx-event.mjs';
4
+ export { isArray, isAsync, isBoolean, isFunc, isMap, isNumber, isObject, isPromise, isSet, isString, isWeakMap, typeOf } from './type-util/type-util.mjs';
5
+ export { clearCookie, createUUID, formatHttpParams, generateOrderValue, getCookie, getQueryVariable, isNilOrEmpty, notNilEmpty, setCookie, setUrlQuery } from './util/util.mjs';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 在不改变内存地址的情况下,清空「对象、数组」内的值。
3
+ *
4
+ * @export
5
+ * @param {unknown} data
6
+ */
7
+ function clearAll(data) {
8
+ if (data instanceof Array) {
9
+ if (data && data.length > 0) {
10
+ data.splice(0, data.length);
11
+ }
12
+ }
13
+ else if (data instanceof Object) {
14
+ if (data) {
15
+ for (const key in data) {
16
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
17
+ delete data[key];
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+
24
+ export { clearAll };
@@ -0,0 +1,94 @@
1
+ import { QXEventEmitter } from '../qx-event-emitter/qx-event-emitter.mjs';
2
+
3
+ /**
4
+ * 事件
5
+ *
6
+ * @author chitanda
7
+ * @date 2022-08-30 13:08:53
8
+ * @export
9
+ * @class QXEvent
10
+ * @template T
11
+ */
12
+ class QXEvent {
13
+ /**
14
+ * Creates an instance of QXEvent.
15
+ * @param {number} [maxListeners] 最大单个事件监听个数
16
+ * @memberof QXEvent
17
+ */
18
+ constructor(maxListeners) {
19
+ this.e = new QXEventEmitter();
20
+ // 设置最大监控事件数量
21
+ this.e.setMaxListeners(maxListeners || 300);
22
+ }
23
+ /**
24
+ * 获取指定事件当前监听个数
25
+ *
26
+ * @author chitanda
27
+ * @date 2022-10-26 19:10:39
28
+ * @template K
29
+ * @param {K} name
30
+ * @return {*} {number}
31
+ */
32
+ getSize(name) {
33
+ return this.e.getSize(name);
34
+ }
35
+ /**
36
+ * 订阅事件
37
+ *
38
+ * @author chitanda
39
+ * @date 2022-08-21 18:08:31
40
+ * @template K
41
+ * @param {K} name
42
+ * @param {(...args: Parameters<T[K]>) => ReturnType<T[K]>} cb
43
+ */
44
+ on(name, cb) {
45
+ this.e.addListener(name, cb);
46
+ }
47
+ /**
48
+ * 取消订阅事件
49
+ *
50
+ * @author chitanda
51
+ * @date 2022-08-21 18:08:46
52
+ * @template K
53
+ * @param {K} name
54
+ * @param {(...args: Parameters<T[K]>) => ReturnType<T[K]>} cb
55
+ */
56
+ off(name, cb) {
57
+ this.e.removeListener(name, cb);
58
+ }
59
+ /**
60
+ * 发送事件
61
+ *
62
+ * @template K
63
+ * @param {K} name
64
+ * @param {T[K]} [arg]
65
+ * @memberof QXEvent
66
+ */
67
+ emit(name, ...args) {
68
+ this.e.emit(name, ...args);
69
+ }
70
+ /**
71
+ * 发送事件,并等待所有监听器执行完毕
72
+ *
73
+ * @author chitanda
74
+ * @date 2022-08-21 18:08:30
75
+ * @template K
76
+ * @param {K} name
77
+ * @param {...Parameters<T[K]>} args
78
+ * @return {*} {(Promise<Awaited<ReturnType<T[K]>>[]>)}
79
+ */
80
+ asyncEmit(name, ...args) {
81
+ return this.e.asyncEmit(name, ...args);
82
+ }
83
+ /**
84
+ * 释放所有事件监听
85
+ *
86
+ * @author chitanda
87
+ * @date 2022-08-30 17:08:09
88
+ */
89
+ reset() {
90
+ this.e.reset();
91
+ }
92
+ }
93
+
94
+ export { QXEvent };
@@ -0,0 +1,146 @@
1
+ import { clearAll } from '../object/object.mjs';
2
+
3
+ /**
4
+ * 事件
5
+ *
6
+ * @author chitanda
7
+ * @date 2022-08-30 17:08:14
8
+ * @export
9
+ * @class QXEventEmitter
10
+ */
11
+ class QXEventEmitter {
12
+ constructor() {
13
+ /**
14
+ * 事件组
15
+ *
16
+ * @private
17
+ * @type {Map<string, any[]>}
18
+ * @memberof QXEventEmitter
19
+ */
20
+ this.map = new Map();
21
+ /**
22
+ * 最大事件监听数量
23
+ *
24
+ * @private
25
+ * @type {number}
26
+ * @memberof QXEventEmitter
27
+ */
28
+ this.maxListeners = 100;
29
+ }
30
+ /**
31
+ * 设置单个事件最大监听数量
32
+ *
33
+ * @param {number} num
34
+ * @memberof QXEventEmitter
35
+ */
36
+ setMaxListeners(num) {
37
+ this.maxListeners = num;
38
+ }
39
+ /**
40
+ * 获取指定事件当前监听个数
41
+ *
42
+ * @author chitanda
43
+ * @date 2022-10-26 19:10:54
44
+ * @param {string} name
45
+ * @return {*} {number}
46
+ */
47
+ getSize(name) {
48
+ if (this.map.has(name)) {
49
+ const events = this.map.get(name);
50
+ return events.length;
51
+ }
52
+ return 0;
53
+ }
54
+ /**
55
+ * 订阅事件
56
+ *
57
+ * @author chitanda
58
+ * @date 2022-08-21 18:08:36
59
+ * @param {string} name
60
+ * @param {(...args: AsArray<any>) => unknown} fn
61
+ */
62
+ addListener(name, fn) {
63
+ if (fn instanceof Function) {
64
+ if (!this.map.has(name)) {
65
+ this.map.set(name, []);
66
+ }
67
+ const events = this.map.get(name);
68
+ if (events.length < this.maxListeners) {
69
+ events.push(fn);
70
+ }
71
+ else {
72
+ throw new Error(`事件监听已达最大上限[${this.maxListeners}],无法新增监听!`);
73
+ }
74
+ }
75
+ }
76
+ /**
77
+ * 取消订阅
78
+ *
79
+ * @author chitanda
80
+ * @date 2022-08-21 18:08:30
81
+ * @param {string} name
82
+ * @param {(...args: AsArray<any>) => unknown} fn
83
+ */
84
+ removeListener(name, fn) {
85
+ if (this.map.has(name)) {
86
+ const events = this.map.get(name);
87
+ if (events.length > 0) {
88
+ for (let i = 0; i < events.length; i++) {
89
+ const item = events[i];
90
+ if (item === fn) {
91
+ events.splice(i, 1);
92
+ break;
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ /**
99
+ * 发送事件
100
+ *
101
+ * @author chitanda
102
+ * @date 2022-08-21 18:08:00
103
+ * @param {string} name
104
+ * @param {...AsArray<any>} args
105
+ */
106
+ emit(name, ...args) {
107
+ if (this.map.has(name)) {
108
+ const events = this.map.get(name);
109
+ events.forEach((fn) => {
110
+ fn(...args);
111
+ });
112
+ }
113
+ }
114
+ /**
115
+ * 等待所有事件执行完毕
116
+ *
117
+ * @author chitanda
118
+ * @date 2022-08-21 18:08:44
119
+ * @template R
120
+ * @param {string} name
121
+ * @param {...AsArray<any>} args
122
+ * @return {*} {Promise<R[]>}
123
+ */
124
+ async asyncEmit(name, ...args) {
125
+ if (this.map.has(name)) {
126
+ const events = this.map.get(name);
127
+ const all = events.map((fn) => fn(...args));
128
+ return Promise.all(all);
129
+ }
130
+ return [];
131
+ }
132
+ /**
133
+ * 释放所有事件监听
134
+ *
135
+ * @author chitanda
136
+ * @date 2022-08-30 17:08:04
137
+ */
138
+ reset() {
139
+ this.map.forEach(val => {
140
+ clearAll(val);
141
+ });
142
+ this.map.clear();
143
+ }
144
+ }
145
+
146
+ export { QXEventEmitter };
@@ -0,0 +1,149 @@
1
+ const { toString } = Object.prototype;
2
+ /**
3
+ * 是否为方法
4
+ *
5
+ * @export
6
+ * @param {*} fn 需要判断的方法
7
+ * @return {*} {boolean}
8
+ */
9
+ function isFunc(fn) {
10
+ return typeOf(fn) === 'function';
11
+ }
12
+ /**
13
+ * 是否为异步方法
14
+ *
15
+ * @export
16
+ * @param {*} fn 需要判断的方法
17
+ * @return {*} {boolean}
18
+ */
19
+ function isAsync(fn) {
20
+ return toString.call(fn) === '[object AsyncFunction]';
21
+ }
22
+ /**
23
+ * 是否为Promise对象
24
+ *
25
+ * @export
26
+ * @param {*} obj
27
+ * @return {*} {boolean}
28
+ */
29
+ function isPromise(obj) {
30
+ return toString.call(obj) === '[object Promise]';
31
+ }
32
+ /**
33
+ * 是否为对象类型
34
+ *
35
+ * @export
36
+ * @param {*} obj
37
+ * @return {*} {boolean}
38
+ */
39
+ function isObject(obj) {
40
+ return typeOf(obj) === 'object';
41
+ }
42
+ /**
43
+ * 是否为数组类型
44
+ *
45
+ * @export
46
+ * @param {*} obj
47
+ * @return {*} {boolean}
48
+ */
49
+ function isArray(obj) {
50
+ return typeOf(obj) === 'array';
51
+ }
52
+ /**
53
+ * 是否为 Map 类型
54
+ *
55
+ * @author chitanda
56
+ * @date 2022-09-07 23:09:05
57
+ * @export
58
+ * @param {unknown} obj
59
+ * @return {*} {boolean}
60
+ */
61
+ function isMap(obj) {
62
+ return typeOf(obj) === 'map';
63
+ }
64
+ /**
65
+ * 是否为 WeakMap 类型
66
+ *
67
+ * @author chitanda
68
+ * @date 2022-09-07 23:09:25
69
+ * @export
70
+ * @param {unknown} obj
71
+ * @return {*} {boolean}
72
+ */
73
+ function isWeakMap(obj) {
74
+ return typeOf(obj) === 'weakmap';
75
+ }
76
+ /**
77
+ * 是否为 Set 类型
78
+ *
79
+ * @author chitanda
80
+ * @date 2022-09-07 23:09:54
81
+ * @export
82
+ * @param {unknown} obj
83
+ * @return {*} {boolean}
84
+ */
85
+ function isSet(obj) {
86
+ return typeOf(obj) === 'set';
87
+ }
88
+ /**
89
+ * 是否为字符串类型
90
+ *
91
+ * @export
92
+ * @param {*} obj
93
+ * @return {*} {boolean}
94
+ */
95
+ function isString(obj) {
96
+ return typeOf(obj) === 'string';
97
+ }
98
+ /**
99
+ * 是否为数值类型
100
+ *
101
+ * @export
102
+ * @param {*} obj
103
+ * @return {*} {boolean}
104
+ */
105
+ function isNumber(obj) {
106
+ return typeOf(obj) === 'number';
107
+ }
108
+ /**
109
+ * 是否为布尔类型
110
+ *
111
+ * @export
112
+ * @param {*} obj
113
+ * @return {*} {boolean}
114
+ */
115
+ function isBoolean(obj) {
116
+ return typeOf(obj) === 'boolean';
117
+ }
118
+ /**
119
+ * 支持判断的数据类型
120
+ */
121
+ const typeMap = {
122
+ '[object Boolean]': 'boolean',
123
+ '[object Number]': 'number',
124
+ '[object String]': 'string',
125
+ '[object Function]': 'function',
126
+ '[object Array]': 'array',
127
+ '[object Date]': 'date',
128
+ '[object RegExp]': 'regExp',
129
+ '[object Undefined]': 'undefined',
130
+ '[object Null]': 'null',
131
+ '[object Object]': 'object',
132
+ '[object Set]': 'set',
133
+ '[object Map]': 'map',
134
+ '[object WeakMap]': 'weakmap',
135
+ };
136
+ /**
137
+ * 判断数据类型
138
+ *
139
+ * @author chitanda
140
+ * @date 2021-05-18 11:05:23
141
+ * @export
142
+ * @param {*} obj 需要判断的数据
143
+ * @return {*} {('boolean' | 'number' | 'string' | 'function' | 'array' | 'date' | 'regExp' | 'undefined' | 'null' | 'object')}
144
+ */
145
+ function typeOf(obj) {
146
+ return typeMap[toString.call(obj)];
147
+ }
148
+
149
+ export { isArray, isAsync, isBoolean, isFunc, isMap, isNumber, isObject, isPromise, isSet, isString, isWeakMap, typeOf };