@fangzhongya/utils 0.0.11 → 0.0.16

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 (158) hide show
  1. package/README.md +5 -1
  2. package/dist/basic/array/index.cjs +11 -7
  3. package/dist/basic/array/index.d.cts +1 -0
  4. package/dist/basic/array/index.d.ts +1 -0
  5. package/dist/basic/array/index.js +11 -7
  6. package/dist/basic/array/sortObj.cjs +7 -0
  7. package/dist/basic/array/sortObj.d.cts +10 -0
  8. package/dist/basic/array/sortObj.d.ts +10 -0
  9. package/dist/basic/array/sortObj.js +7 -0
  10. package/dist/basic/index.cjs +22 -17
  11. package/dist/basic/index.d.cts +8 -3
  12. package/dist/basic/index.d.ts +8 -3
  13. package/dist/basic/index.js +21 -16
  14. package/dist/basic/object/index.cjs +14 -8
  15. package/dist/basic/object/index.d.cts +1 -0
  16. package/dist/basic/object/index.d.ts +1 -0
  17. package/dist/basic/object/index.js +13 -7
  18. package/dist/basic/object/objValue.cjs +9 -0
  19. package/dist/basic/object/objValue.d.cts +7 -0
  20. package/dist/basic/object/objValue.d.ts +7 -0
  21. package/dist/basic/object/objValue.js +9 -0
  22. package/dist/basic/string/appearNum.cjs +2 -2
  23. package/dist/basic/string/appearNum.js +1 -1
  24. package/dist/basic/string/getStrNunPosit.cjs +7 -0
  25. package/dist/basic/string/getStrNunPosit.d.cts +10 -0
  26. package/dist/basic/string/getStrNunPosit.d.ts +10 -0
  27. package/dist/basic/string/getStrNunPosit.js +7 -0
  28. package/dist/basic/string/index.cjs +26 -7
  29. package/dist/basic/string/index.d.cts +3 -0
  30. package/dist/basic/string/index.d.ts +3 -0
  31. package/dist/basic/string/index.js +29 -10
  32. package/dist/basic/string/startsNum.cjs +7 -0
  33. package/dist/basic/string/startsNum.d.cts +9 -0
  34. package/dist/basic/string/startsNum.d.ts +9 -0
  35. package/dist/basic/string/startsNum.js +7 -0
  36. package/dist/basic/string/toFunction.cjs +2 -2
  37. package/dist/basic/string/toFunction.d.cts +15 -7
  38. package/dist/basic/string/toFunction.d.ts +15 -7
  39. package/dist/basic/string/toFunction.js +1 -1
  40. package/dist/basic/string/toJson.cjs +3 -3
  41. package/dist/basic/string/toJson.d.cts +2 -5
  42. package/dist/basic/string/toJson.d.ts +2 -5
  43. package/dist/basic/string/toJson.js +2 -2
  44. package/dist/basic/string/toJsons.cjs +15 -0
  45. package/dist/basic/string/toJsons.d.cts +60 -0
  46. package/dist/basic/string/toJsons.d.ts +60 -0
  47. package/dist/basic/string/toJsons.js +15 -0
  48. package/dist/chunk-2H3KVSFA.cjs +16 -0
  49. package/dist/{chunk-LZ7JIJ4I.cjs → chunk-2J3S75C6.cjs} +6 -2
  50. package/dist/{chunk-6RIGEV6G.cjs → chunk-3DD7YCN2.cjs} +2 -2
  51. package/dist/chunk-3NBXSBFM.js +29 -0
  52. package/dist/{chunk-VQKOHGV5.cjs → chunk-4BGJIMWM.cjs} +9 -5
  53. package/dist/chunk-5HC662VK.js +432 -0
  54. package/dist/chunk-754Z5VW6.js +29 -0
  55. package/dist/chunk-7O4MJOHM.js +142 -0
  56. package/dist/{chunk-X4WTO4NR.js → chunk-CMBQ66JH.js} +5 -1
  57. package/dist/chunk-E4WBX6J5.cjs +29 -0
  58. package/dist/chunk-ETMYYVQJ.cjs +432 -0
  59. package/dist/{chunk-R5TH6GQE.js → chunk-FSIQKHKH.js} +5 -5
  60. package/dist/{chunk-QJVB3JIZ.js → chunk-HWR2FRME.js} +1 -1
  61. package/dist/{chunk-JJLYV6GY.js → chunk-IEQHKLEL.js} +12 -6
  62. package/dist/chunk-ILJLXJ5O.cjs +15 -0
  63. package/dist/chunk-JHV27P2Q.cjs +54 -0
  64. package/dist/{chunk-SNABGVNO.js → chunk-LPMR5W6M.js} +1 -1
  65. package/dist/{chunk-2KT66KQH.js → chunk-LU22MUUS.js} +10 -6
  66. package/dist/chunk-NESVPZNF.cjs +29 -0
  67. package/dist/chunk-O34QAOO7.js +16 -0
  68. package/dist/{chunk-3HXQ7TGV.cjs → chunk-OJBZ7UUC.cjs} +1 -1
  69. package/dist/{chunk-YHLI3SF7.js → chunk-OVHYLUAS.js} +8 -0
  70. package/dist/chunk-P7AWHISY.js +15 -0
  71. package/dist/chunk-PLNZCEDI.js +442 -0
  72. package/dist/chunk-PSHKOVLY.cjs +24 -0
  73. package/dist/{chunk-V5HVA7TW.cjs → chunk-PV2N6PF2.cjs} +8 -0
  74. package/dist/chunk-QXK4IUBI.cjs +142 -0
  75. package/dist/chunk-RYBJGHXK.cjs +153 -0
  76. package/dist/{chunk-ZRZ5HATA.js → chunk-SE7A43WC.js} +1 -1
  77. package/dist/chunk-U3PZBQ6G.js +54 -0
  78. package/dist/{chunk-SLRWY5FH.cjs → chunk-UGT4QBTM.cjs} +12 -6
  79. package/dist/chunk-UHKL2RG3.cjs +80 -0
  80. package/dist/chunk-USIMBBLW.js +16 -0
  81. package/dist/{chunk-FCCQIHFD.js → chunk-UZ3LZBJ5.js} +1 -1
  82. package/dist/chunk-V2DXOH6B.cjs +442 -0
  83. package/dist/chunk-VJUGYXBC.cjs +70 -0
  84. package/dist/chunk-XQOH3NGZ.js +153 -0
  85. package/dist/chunk-XW3XIK3D.cjs +16 -0
  86. package/dist/chunk-YKNGDK4I.js +80 -0
  87. package/dist/{chunk-GIJMEVTJ.js → chunk-ZEMAXGD5.js} +27 -9
  88. package/dist/index-20jIrGxr.d.ts +36 -0
  89. package/dist/index-B7gdHwF9.d.cts +40 -0
  90. package/dist/{index-EY4Ag8_f.d.cts → index-BU0xla6v.d.cts} +4 -1
  91. package/dist/{index-D92-6As_.d.ts → index-C29DFVeC.d.ts} +3 -1
  92. package/dist/index-C6CeIuau.d.cts +36 -0
  93. package/dist/index-CPO1AFVg.d.ts +14 -0
  94. package/dist/{index-Dm5gvjpr.d.cts → index-C__Goqn1.d.cts} +3 -1
  95. package/dist/index-D1WceQZE.d.ts +9 -0
  96. package/dist/{index-CsP95PJy.d.ts → index-DOq59RNr.d.ts} +4 -1
  97. package/dist/index-DPrdy8Ms.d.ts +40 -0
  98. package/dist/{index-D-JJ6qt2.d.ts → index-IJlghj8j.d.ts} +3 -1
  99. package/dist/index-cuR7l2XV.d.cts +14 -0
  100. package/dist/index-haAz3CpA.d.cts +9 -0
  101. package/dist/{index-BrxHOuw0.d.cts → index-qUiGxoy_.d.cts} +3 -1
  102. package/dist/index.cjs +45 -37
  103. package/dist/index.d.cts +15 -7
  104. package/dist/index.d.ts +15 -7
  105. package/dist/index.js +48 -40
  106. package/dist/judge/index.cjs +57 -5
  107. package/dist/judge/index.d.cts +1 -0
  108. package/dist/judge/index.d.ts +1 -0
  109. package/dist/judge/index.js +57 -5
  110. package/dist/judge/judge.cjs +55 -0
  111. package/dist/judge/judge.d.cts +155 -0
  112. package/dist/judge/judge.d.ts +155 -0
  113. package/dist/judge/judge.js +55 -0
  114. package/dist/judge/matchs.cjs +3 -3
  115. package/dist/judge/matchs.js +2 -2
  116. package/dist/name/index.cjs +3 -3
  117. package/dist/name/index.js +4 -4
  118. package/dist/node/getPort.js +1 -1
  119. package/dist/node/index.js +2 -2
  120. package/dist/tree/index.cjs +11 -2
  121. package/dist/tree/index.d.cts +1 -0
  122. package/dist/tree/index.d.ts +1 -0
  123. package/dist/tree/index.js +10 -1
  124. package/dist/tree/splitGroup.cjs +12 -0
  125. package/dist/tree/splitGroup.d.cts +15 -0
  126. package/dist/tree/splitGroup.d.ts +15 -0
  127. package/dist/tree/splitGroup.js +12 -0
  128. package/dist/urls/getReplaceCompleteUrl.cjs +10 -0
  129. package/dist/urls/getReplaceCompleteUrl.d.cts +9 -0
  130. package/dist/urls/getReplaceCompleteUrl.d.ts +9 -0
  131. package/dist/urls/getReplaceCompleteUrl.js +10 -0
  132. package/dist/urls/getReplaceUrl.cjs +3 -3
  133. package/dist/urls/getReplaceUrl.js +2 -2
  134. package/dist/urls/index.cjs +10 -4
  135. package/dist/urls/index.d.cts +1 -0
  136. package/dist/urls/index.d.ts +1 -0
  137. package/dist/urls/index.js +9 -3
  138. package/package.json +46 -6
  139. package/dist/chunk-45M6CPWK.cjs +0 -52
  140. package/dist/chunk-6YI3CDEW.js +0 -35
  141. package/dist/chunk-AFKJQ4QP.js +0 -35
  142. package/dist/chunk-JYPJ5QJ5.cjs +0 -35
  143. package/dist/chunk-T7XQBASK.js +0 -28
  144. package/dist/chunk-U5TCBGC3.cjs +0 -28
  145. package/dist/chunk-WMZ6P3AK.cjs +0 -24
  146. package/dist/chunk-ZJIRJ4YJ.cjs +0 -35
  147. package/dist/index-BWAB-b69.d.ts +0 -10
  148. package/dist/index-CIOxFVHu.d.ts +0 -9
  149. package/dist/index-CVNtXK0N.d.ts +0 -14
  150. package/dist/index-D-5HNg2W.d.cts +0 -14
  151. package/dist/index-DBBlm0PZ.d.cts +0 -26
  152. package/dist/index-DTk8hXm8.d.cts +0 -10
  153. package/dist/index-DfmnOk56.d.cts +0 -9
  154. package/dist/index-DjtNMmhM.d.ts +0 -26
  155. package/dist/{chunk-IVDRKJ33.js → chunk-BFN33JM5.js} +3 -3
  156. package/dist/{chunk-ZXWKQRGH.cjs → chunk-BG2YS767.cjs} +2 -2
  157. package/dist/{chunk-NGQKVTCR.cjs → chunk-T22I7TJQ.cjs} +3 -3
  158. package/dist/{chunk-FRGDQOX4.js → chunk-T2QKEABG.js} +3 -3
@@ -0,0 +1,15 @@
1
+ // packages/basic/string/startsNum.ts
2
+ function startsNum(str, substring) {
3
+ if (substring.length === 0) return 0;
4
+ let count = 0;
5
+ let index = 0;
6
+ while (str.startsWith(substring, index)) {
7
+ count++;
8
+ index += substring.length;
9
+ }
10
+ return count;
11
+ }
12
+
13
+ export {
14
+ startsNum
15
+ };
@@ -0,0 +1,442 @@
1
+ // packages/judge/judge.ts
2
+ function judgeTest(a, b) {
3
+ return a.test(b);
4
+ }
5
+ function isEmpty(str) {
6
+ return typeof str == "undefined" || str == null || (str = str + "", str.trim() == "" || str.trim() == "undefined" || str.trim() == "null");
7
+ }
8
+ function isNotEmpty(str) {
9
+ return !isEmpty(str);
10
+ }
11
+ function isDate(strValue) {
12
+ if (isEmpty(strValue)) return false;
13
+ let r = strValue.match(/^(\d{4})(-|\/)(\d{2})\2(\d{2})$/);
14
+ if (r == null) return false;
15
+ let d = new Date(Number(r[1]), Number(r[3]) - 1, Number(r[4]));
16
+ return d.getFullYear() == Number(r[1]) && d.getMonth() + 1 == Number(r[3]) && d.getDate() == Number(r[4]);
17
+ }
18
+ function isDateTime(str) {
19
+ let reg = /^(\d{4})(-|\/)(\d{2})\2(\d{2}) (\d{2}):(\d{2}):(\d{2})$/;
20
+ let r = str.match(reg);
21
+ if (r == null) return false;
22
+ let d = new Date(
23
+ Number(r[1]),
24
+ Number(r[3]) - 1,
25
+ Number(r[4]),
26
+ Number(r[5]),
27
+ Number(r[6]),
28
+ Number(r[7])
29
+ );
30
+ return d.getFullYear() == Number(r[1]) && d.getMonth() + 1 == Number(r[3]) && d.getDate() == Number(r[4]) && d.getHours() == Number(r[5]) && d.getMinutes() == Number(r[6]) && d.getSeconds() == Number(r[7]);
31
+ }
32
+ function isAlphaNumeric(strValue) {
33
+ if (isEmpty(strValue)) return false;
34
+ let pattern = /^[A-Za-z0-9]+$/;
35
+ return judgeTest(pattern, strValue);
36
+ }
37
+ function isCnAndEnNumeric(strValue) {
38
+ let pattern = /^[_0-9a-zA-Z\u4e00-\u9fa5]+$/;
39
+ return judgeTest(pattern, strValue);
40
+ }
41
+ function isEnNumeric(strValue) {
42
+ let pattern = /^[_0-9a-zA-Z]+$/;
43
+ return judgeTest(pattern, strValue);
44
+ }
45
+ function isCnAndEn(strValue) {
46
+ if (isEmpty(strValue)) return false;
47
+ let pattern = /^[\u4e00-\u9fa5]+$/;
48
+ return judgeTest(pattern, strValue);
49
+ }
50
+ function isEmail(strValue) {
51
+ if (isEmpty(strValue)) return false;
52
+ let pattern = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
53
+ return judgeTest(pattern, strValue);
54
+ }
55
+ function isMoney(strValue) {
56
+ if (isEmpty(strValue)) return false;
57
+ let pattern = /^[+-]?\d+(,\d{3})*(\.\d+)?$/;
58
+ return judgeTest(pattern, strValue);
59
+ }
60
+ function isNumeric(strValue) {
61
+ if (isEmpty(strValue)) return false;
62
+ let pattern = /^[0-9]*$/;
63
+ return judgeTest(pattern, strValue);
64
+ }
65
+ function isNumberFloat(strValue) {
66
+ if (isEmpty(strValue)) return false;
67
+ let pattern = /^\d+(\.\d+)?$/;
68
+ return judgeTest(pattern, strValue);
69
+ }
70
+ function isMobile(strValue) {
71
+ if (isEmpty(strValue)) return false;
72
+ let pattern = /^(1)[0-9]{10}$/;
73
+ return judgeTest(pattern, strValue);
74
+ }
75
+ function isPhone(strValue) {
76
+ if (isEmpty(strValue)) return false;
77
+ let pattern = /(^\(\d{3,5}\)\d{6,8}(-\d{2,8})?$)|(^\d+-\d+$)|(^(1)[0-9]{10}$)/;
78
+ return judgeTest(pattern, strValue);
79
+ }
80
+ function isFax(strValue) {
81
+ if (isEmpty(strValue)) return false;
82
+ let pattern = /^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
83
+ return judgeTest(pattern, strValue);
84
+ }
85
+ function isTel(strValue) {
86
+ if (isEmpty(strValue)) return false;
87
+ let pattern = /^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
88
+ return judgeTest(pattern, strValue);
89
+ }
90
+ function isPostalCode(strValue) {
91
+ if (isEmpty(strValue)) return false;
92
+ let pattern = /(^\d{6}$)/;
93
+ return judgeTest(pattern, strValue);
94
+ }
95
+ function isURL(strValue) {
96
+ if (isEmpty(strValue)) return false;
97
+ let pattern = /^(http|https|ftp):\/\/(\w+\.)+[a-z]{2,3}(\/\w+)*(\/\w+\.\w+)*(\?\w+=\w*(&\w+=\w*)*)*/;
98
+ return judgeTest(pattern, strValue);
99
+ }
100
+ function isCardID(strValue) {
101
+ if (isEmpty(strValue)) {
102
+ return false;
103
+ }
104
+ strValue = strValue.toUpperCase();
105
+ let vcity = {
106
+ 11: "\u5317\u4EAC",
107
+ 12: "\u5929\u6D25",
108
+ 13: "\u6CB3\u5317",
109
+ 14: "\u5C71\u897F",
110
+ 15: "\u5185\u8499\u53E4",
111
+ 21: "\u8FBD\u5B81",
112
+ 22: "\u5409\u6797",
113
+ 23: "\u9ED1\u9F99\u6C5F",
114
+ 31: "\u4E0A\u6D77",
115
+ 32: "\u6C5F\u82CF",
116
+ 33: "\u6D59\u6C5F",
117
+ 34: "\u5B89\u5FBD",
118
+ 35: "\u798F\u5EFA",
119
+ 36: "\u6C5F\u897F",
120
+ 37: "\u5C71\u4E1C",
121
+ 41: "\u6CB3\u5357",
122
+ 42: "\u6E56\u5317",
123
+ 43: "\u6E56\u5357",
124
+ 44: "\u5E7F\u4E1C",
125
+ 45: "\u5E7F\u897F",
126
+ 46: "\u6D77\u5357",
127
+ 50: "\u91CD\u5E86",
128
+ 51: "\u56DB\u5DDD",
129
+ 52: "\u8D35\u5DDE",
130
+ 53: "\u4E91\u5357",
131
+ 54: "\u897F\u85CF",
132
+ 61: "\u9655\u897F",
133
+ 62: "\u7518\u8083",
134
+ 63: "\u9752\u6D77",
135
+ 64: "\u5B81\u590F",
136
+ 65: "\u65B0\u7586",
137
+ 71: "\u53F0\u6E7E",
138
+ 81: "\u9999\u6E2F",
139
+ 82: "\u6FB3\u95E8",
140
+ 91: "\u56FD\u5916"
141
+ };
142
+ let pattern = /(^\d{15}$)|(^\d{17}(\d|X)$)/;
143
+ if (judgeTest(pattern, strValue) === false) {
144
+ return false;
145
+ }
146
+ let province = strValue.substring(0, 2);
147
+ if (vcity[province] == void 0) {
148
+ return false;
149
+ }
150
+ let len = strValue.length;
151
+ if (len == 15) {
152
+ let re_fifteen = /^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/;
153
+ let arr_data = strValue.match(re_fifteen) || [];
154
+ let year = Number("19" + arr_data[2]);
155
+ let month = Number(arr_data[3]);
156
+ let day = Number(arr_data[4]);
157
+ let birthday = /* @__PURE__ */ new Date("19" + year + "/" + month + "/" + day);
158
+ birthday.setFullYear(year);
159
+ birthday.setMonth(month - 1);
160
+ birthday.setDate(day);
161
+ let now = /* @__PURE__ */ new Date();
162
+ let now_year = now.getFullYear();
163
+ if (birthday.getFullYear() == year && birthday.getMonth() + 1 == month && birthday.getDate() == day) {
164
+ let time = now_year - year;
165
+ if (!(time >= 3 && time <= 200)) {
166
+ return false;
167
+ }
168
+ } else {
169
+ return false;
170
+ }
171
+ }
172
+ if (len == 18) {
173
+ let re_eighteen = /^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/;
174
+ let arr_data = strValue.match(re_eighteen) || [];
175
+ let year = Number(arr_data[2]);
176
+ let month = Number(arr_data[3]);
177
+ let day = Number(arr_data[4]);
178
+ let birthday = /* @__PURE__ */ new Date(year + "/" + month + "/" + day);
179
+ birthday.setFullYear(year);
180
+ birthday.setMonth(month - 1);
181
+ birthday.setDate(day);
182
+ let now = /* @__PURE__ */ new Date();
183
+ let now_year = now.getFullYear();
184
+ if (birthday.getFullYear() == year && birthday.getMonth() + 1 == month && birthday.getDate() == day) {
185
+ let time = now_year - year;
186
+ if (!(time >= 3 && time <= 200)) {
187
+ return false;
188
+ }
189
+ } else {
190
+ return false;
191
+ }
192
+ }
193
+ if (strValue.length == 15) {
194
+ let arrInt = new Array(
195
+ 7,
196
+ 9,
197
+ 10,
198
+ 5,
199
+ 8,
200
+ 4,
201
+ 2,
202
+ 1,
203
+ 6,
204
+ 3,
205
+ 7,
206
+ 9,
207
+ 10,
208
+ 5,
209
+ 8,
210
+ 4,
211
+ 2
212
+ );
213
+ let arrCh = new Array(
214
+ "1",
215
+ "0",
216
+ "X",
217
+ "9",
218
+ "8",
219
+ "7",
220
+ "6",
221
+ "5",
222
+ "4",
223
+ "3",
224
+ "2"
225
+ );
226
+ let cardTemp = 0, i;
227
+ strValue = strValue.substring(0, 6) + "19" + strValue.substring(6, strValue.length - 6);
228
+ for (i = 0; i < 17; i++) {
229
+ cardTemp += Number(strValue.substring(i, 1)) * arrInt[i];
230
+ }
231
+ strValue += arrCh[cardTemp % 11];
232
+ }
233
+ if (strValue.length == 18) {
234
+ let arrInt = new Array(
235
+ 7,
236
+ 9,
237
+ 10,
238
+ 5,
239
+ 8,
240
+ 4,
241
+ 2,
242
+ 1,
243
+ 6,
244
+ 3,
245
+ 7,
246
+ 9,
247
+ 10,
248
+ 5,
249
+ 8,
250
+ 4,
251
+ 2
252
+ );
253
+ let arrCh = new Array(
254
+ "1",
255
+ "0",
256
+ "X",
257
+ "9",
258
+ "8",
259
+ "7",
260
+ "6",
261
+ "5",
262
+ "4",
263
+ "3",
264
+ "2"
265
+ );
266
+ let cardTemp = 0, i, valnum;
267
+ for (i = 0; i < 17; i++) {
268
+ cardTemp += Number.parseInt(strValue.substring(i, 1)) * arrInt[i];
269
+ }
270
+ valnum = arrCh[cardTemp % 11];
271
+ if (valnum != strValue.substring(17, 1)) {
272
+ return false;
273
+ }
274
+ }
275
+ return true;
276
+ }
277
+ function isPwd(strValue) {
278
+ if (isEmpty(strValue)) return false;
279
+ let pattern = /^[0-9]{6}$/;
280
+ return judgeTest(pattern, strValue);
281
+ }
282
+ function isStrongPwd(strValue, filters = []) {
283
+ if (!judgeTest(/^\d{6}$/, strValue)) return false;
284
+ if (judgeTest(/([\d])\1{2}/, strValue)) return false;
285
+ let str = strValue.replace(/\d/g, ($0, pos) => {
286
+ return Number.parseInt($0) - Number.parseInt(pos) + "";
287
+ });
288
+ if (judgeTest(/^(\d)\1+$/, str)) return false;
289
+ str = strValue.replace(/\d/g, ($0, pos) => {
290
+ return Number.parseInt($0) + pos;
291
+ });
292
+ if (judgeTest(/^(\d)\1+$/, str)) return false;
293
+ let temp = "";
294
+ for (let i = 0; i < strValue.length; i++) {
295
+ let c = strValue.charAt(i);
296
+ if (temp.indexOf(c) == -1) {
297
+ temp += c;
298
+ }
299
+ }
300
+ if (temp.length <= 2) return false;
301
+ let flag = true;
302
+ let map = {};
303
+ for (let i = 0; i < strValue.length; i++) {
304
+ let c = strValue.charAt(i);
305
+ if (isEmpty(map[c])) {
306
+ map[c] = 0;
307
+ }
308
+ map[c] = map[c] + 1;
309
+ if (map[c] >= strValue.length / 2) {
310
+ flag = false;
311
+ }
312
+ }
313
+ if (flag == false) {
314
+ return false;
315
+ }
316
+ if (filters && filters.length > 0) {
317
+ for (let i = 0; i < filters.length; i++) {
318
+ let filter = filters[i];
319
+ if (filter.indexOf(strValue) > -1) {
320
+ return false;
321
+ }
322
+ }
323
+ }
324
+ return true;
325
+ }
326
+ function isBankCode(strValue) {
327
+ strValue = strValue.trim();
328
+ if (!isNumeric(strValue)) {
329
+ return false;
330
+ }
331
+ let length = strValue.length;
332
+ if (length < 12) {
333
+ return false;
334
+ } else if (length > 19 || length == 18) {
335
+ return true;
336
+ }
337
+ let flag = true;
338
+ let i = 0, mark = 0, temp = 0;
339
+ while (i < length - 1) {
340
+ mark += Number.parseInt(strValue.charAt(i));
341
+ i++;
342
+ temp = Number.parseInt(strValue.charAt(i)) * 2;
343
+ i++;
344
+ mark = Math.floor(temp / 10) + temp % 10;
345
+ }
346
+ if (mark % 10 == 0) {
347
+ flag = true;
348
+ } else {
349
+ flag = Number.parseInt(strValue.charAt(length - 1)) == 10 - mark % 10 || Number.parseInt(strValue.charAt(length - 1)) == mark % 10;
350
+ }
351
+ if (!flag) {
352
+ let lastNum = strValue.substring(
353
+ strValue.length - 1,
354
+ 1
355
+ );
356
+ let first15Num = strValue.substring(0, strValue.length - 1);
357
+ let newArr = [];
358
+ for (let i2 = first15Num.length - 1; i2 > -1; i2--) {
359
+ newArr.push(first15Num.substring(i2, 1));
360
+ }
361
+ let arrJiShu = [];
362
+ let arrJiShu2 = [];
363
+ let arrOuShu = [];
364
+ for (let j = 0; j < newArr.length; j++) {
365
+ if ((j + 1) % 2 == 1) {
366
+ if (Number.parseInt(newArr[j]) * 2 < 9)
367
+ arrJiShu.push(Number.parseInt(newArr[j]) * 2);
368
+ else arrJiShu2.push(Number.parseInt(newArr[j]) * 2);
369
+ } else arrOuShu.push(newArr[j]);
370
+ }
371
+ let jishu_child1 = [];
372
+ let jishu_child2 = [];
373
+ for (let h = 0; h < arrJiShu2.length; h++) {
374
+ jishu_child1.push(arrJiShu2[h] % 10);
375
+ jishu_child2.push(arrJiShu2[h] / 10);
376
+ }
377
+ let sumJiShu = 0;
378
+ let sumOuShu = 0;
379
+ let sumJiShuChild1 = 0;
380
+ let sumJiShuChild2 = 0;
381
+ let sumTotal = 0;
382
+ for (let m = 0; m < arrJiShu.length; m++) {
383
+ sumJiShu = sumJiShu + arrJiShu[m];
384
+ }
385
+ for (let n = 0; n < arrOuShu.length; n++) {
386
+ sumOuShu = sumOuShu + Number.parseInt(arrOuShu[n]);
387
+ }
388
+ for (let p = 0; p < jishu_child1.length; p++) {
389
+ sumJiShuChild1 = sumJiShuChild1 + jishu_child1[p];
390
+ sumJiShuChild2 = sumJiShuChild2 + jishu_child2[p];
391
+ }
392
+ sumTotal = sumJiShu + sumOuShu + sumJiShuChild1 + sumJiShuChild2;
393
+ let k = sumTotal % 10 == 0 ? 10 : sumTotal % 10;
394
+ let luhm = 10 - k;
395
+ lastNum = Number.parseInt(lastNum);
396
+ flag = lastNum == luhm || luhm % lastNum == 0 || lastNum % luhm == 0 || lastNum + luhm == 10;
397
+ }
398
+ return flag;
399
+ }
400
+ function isQq(a) {
401
+ if (isEmpty(a)) return false;
402
+ let d = /^[1-9]\d{4,11}$/;
403
+ return judgeTest(d, a);
404
+ }
405
+ function isFormatNumber(a, b = 2) {
406
+ if (isEmpty(a)) return false;
407
+ let d = new RegExp("^[0-9]+.[0-9]{" + b + "}$");
408
+ return judgeTest(d, a);
409
+ }
410
+ function isWeChat(a) {
411
+ if (isEmpty(a)) return false;
412
+ let d = /^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$/;
413
+ return judgeTest(d, a);
414
+ }
415
+
416
+ export {
417
+ isEmpty,
418
+ isNotEmpty,
419
+ isDate,
420
+ isDateTime,
421
+ isAlphaNumeric,
422
+ isCnAndEnNumeric,
423
+ isEnNumeric,
424
+ isCnAndEn,
425
+ isEmail,
426
+ isMoney,
427
+ isNumeric,
428
+ isNumberFloat,
429
+ isMobile,
430
+ isPhone,
431
+ isFax,
432
+ isTel,
433
+ isPostalCode,
434
+ isURL,
435
+ isCardID,
436
+ isPwd,
437
+ isStrongPwd,
438
+ isBankCode,
439
+ isQq,
440
+ isFormatNumber,
441
+ isWeChat
442
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkVJUGYXBCcjs = require('./chunk-VJUGYXBC.cjs');
4
+
5
+
6
+ var _chunkUGT4QBTMcjs = require('./chunk-UGT4QBTM.cjs');
7
+
8
+
9
+ var _chunk4BGJIMWMcjs = require('./chunk-4BGJIMWM.cjs');
10
+
11
+
12
+ var _chunk75ZPJI57cjs = require('./chunk-75ZPJI57.cjs');
13
+
14
+ // packages/basic/index.ts
15
+ var basic_exports = {};
16
+ _chunk75ZPJI57cjs.__export.call(void 0, basic_exports, {
17
+ array: () => _chunk4BGJIMWMcjs.array_exports,
18
+ object: () => _chunkUGT4QBTMcjs.object_exports,
19
+ string: () => _chunkVJUGYXBCcjs.string_exports
20
+ });
21
+
22
+
23
+
24
+ exports.basic_exports = basic_exports;
@@ -5,6 +5,11 @@
5
5
  var _chunkYAD5PHVFcjs = require('./chunk-YAD5PHVF.cjs');
6
6
 
7
7
 
8
+
9
+
10
+ var _chunkRYBJGHXKcjs = require('./chunk-RYBJGHXK.cjs');
11
+
12
+
8
13
  var _chunk75ZPJI57cjs = require('./chunk-75ZPJI57.cjs');
9
14
 
10
15
  // packages/tree/index.ts
@@ -12,6 +17,9 @@ var tree_exports = {};
12
17
  _chunk75ZPJI57cjs.__export.call(void 0, tree_exports, {
13
18
  arrayToTree: () => _chunkYAD5PHVFcjs.arrayToTree,
14
19
  getTreeObj: () => _chunkYAD5PHVFcjs.getTreeObj,
20
+ splitGroup: () => _chunkRYBJGHXKcjs.splitGroup,
21
+ splitGroupDitto: () => _chunkRYBJGHXKcjs.splitGroupDitto,
22
+ splitGroupExist: () => _chunkRYBJGHXKcjs.splitGroupExist,
15
23
  treeToArray: () => _chunkYAD5PHVFcjs.treeToArray
16
24
  });
17
25
 
@@ -0,0 +1,142 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// packages/basic/string/toFunction.ts
2
+ function extractParams(paramStr) {
3
+ const result = [];
4
+ let depth = 0;
5
+ let current = "";
6
+ let inString = false;
7
+ let quoteType = "";
8
+ let lastChar = "";
9
+ for (let i = 0; i < paramStr.length; i++) {
10
+ const char = paramStr[i];
11
+ if (lastChar === "\\") {
12
+ current += char;
13
+ lastChar = char;
14
+ continue;
15
+ }
16
+ if (!inString && (char === '"' || char === "'" || char === "`")) {
17
+ inString = true;
18
+ quoteType = char;
19
+ } else if (inString && char === quoteType) {
20
+ inString = false;
21
+ }
22
+ if (quoteType === "`" && char === "$" && i < paramStr.length - 1 && paramStr[i + 1] === "{") {
23
+ depth++;
24
+ } else if (quoteType === "`" && depth > 0 && char === "}") {
25
+ depth--;
26
+ }
27
+ if (char === "," && depth === 0 && !inString) {
28
+ result.push(current.trim());
29
+ current = "";
30
+ } else {
31
+ if (char === "(" || char === "{" || char === "[") depth++;
32
+ else if (char === ")" || char === "}" || char === "]") depth--;
33
+ current += char;
34
+ }
35
+ lastChar = char;
36
+ }
37
+ if (current.trim()) result.push(current.trim());
38
+ return result;
39
+ }
40
+ function toFunction(str, key) {
41
+ try {
42
+ const obj = getFunctionFormat(str);
43
+ if (!_optionalChain([obj, 'optionalAccess', _2 => _2.body])) return void 0;
44
+ const params = obj.param ? extractParams(obj.param) : [];
45
+ if (params.length > 1e3) {
46
+ throw new Error("Too many parameters (max: 1000)");
47
+ }
48
+ if (obj.isAsync) {
49
+ try {
50
+ const fullFunction = `async function${obj.isGenerator ? "*" : ""} ${_nullishCoalesce(_nullishCoalesce(obj.name, () => ( key)), () => ( ""))} (${obj.param}) { ${obj.body} }`;
51
+ return new Function(`return ${fullFunction}`)();
52
+ } catch (error) {
53
+ const fullFunction = `async function${obj.isGenerator ? "*" : ""} (${obj.param}) { ${obj.body} }`;
54
+ return new Function(`return ${fullFunction}`)();
55
+ }
56
+ } else {
57
+ try {
58
+ const fullFunction = `function${obj.isGenerator ? "*" : ""} ${_nullishCoalesce(_nullishCoalesce(obj.name, () => ( key)), () => ( ""))}(${obj.param}) { ${obj.body} }`;
59
+ return new Function(`return (${fullFunction})`)();
60
+ } catch (error) {
61
+ return new Function(...params, obj.body);
62
+ }
63
+ }
64
+ } catch (error) {
65
+ console.error("Function creation failed:", {
66
+ input: str.slice(0, 100),
67
+ error
68
+ });
69
+ return void 0;
70
+ }
71
+ }
72
+ var FUNCTION_REGEX = /^\s*(?:(async)\s+)?(?:function\s*(\*?)\s*(\w*)\s*\(([\s\S]*?)\)|(\*?\s*)\b(\w+)\s*\(([\s\S]*?)\)|\(([\s\S]*?)\)|([^=>,\(\)]+?))\s*(?:=>)?\s*(?:\{([\s\S]*?)\}|([\s\S]*))$/;
73
+ function getFunctionFormat(v) {
74
+ if (!v) return;
75
+ const str = typeof v === "function" ? v.toString() : v;
76
+ const trimmed = str.trim();
77
+ const match = trimmed.match(FUNCTION_REGEX);
78
+ if (!match) {
79
+ console.warn("Unsupported function format:", trimmed.slice(0, 100));
80
+ return;
81
+ }
82
+ const [
83
+ _,
84
+ // 完整匹配
85
+ asyncFlag,
86
+ // 异步标志
87
+ funcGenerator,
88
+ // 函数生成器标志
89
+ funcName,
90
+ // 函数名称
91
+ funcParams,
92
+ // 函数参数
93
+ methodGenerator,
94
+ // 方法生成器标志
95
+ methodName,
96
+ // 方法名称
97
+ methodParams,
98
+ // 方法参数
99
+ arrowParenParams,
100
+ // 箭头函数括号参数
101
+ arrowSingleParam,
102
+ // 箭头函数单参数
103
+ blockBody,
104
+ // 块级函数体
105
+ exprBody
106
+ // 表达式函数体
107
+ ] = match;
108
+ let isAsync = !!asyncFlag;
109
+ let isGenerator = false;
110
+ let name = "";
111
+ let param = "";
112
+ let body = "";
113
+ if (funcParams !== void 0) {
114
+ isGenerator = funcGenerator === "*";
115
+ name = funcName || "";
116
+ param = funcParams;
117
+ body = blockBody || exprBody || "";
118
+ } else if (methodParams !== void 0) {
119
+ isGenerator = _optionalChain([methodGenerator, 'optionalAccess', _3 => _3.includes, 'call', _4 => _4("*")]) || false;
120
+ name = methodName || "";
121
+ param = methodParams;
122
+ body = blockBody || exprBody || "";
123
+ } else if (arrowParenParams !== void 0 || arrowSingleParam !== void 0) {
124
+ param = arrowParenParams || arrowSingleParam || "";
125
+ body = blockBody || exprBody || "";
126
+ if (!blockBody && !/^\s*return\b/.test(body)) {
127
+ body = `return ${body}`;
128
+ }
129
+ }
130
+ return {
131
+ isAsync,
132
+ isGenerator,
133
+ ...name && { name },
134
+ param: param.trim(),
135
+ body: body.trim()
136
+ };
137
+ }
138
+
139
+
140
+
141
+
142
+ exports.toFunction = toFunction; exports.getFunctionFormat = getFunctionFormat;