@szkj/utils 0.0.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/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/index.cjs +1850 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +401 -0
- package/dist/index.d.ts +401 -0
- package/dist/index.js +1698 -0
- package/dist/index.js.map +1 -0
- package/package.json +34 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1850 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var CryptoJS = require('crypto-js');
|
|
4
|
+
var smCrypto = require('sm-crypto');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var CryptoJS__default = /*#__PURE__*/_interopDefault(CryptoJS);
|
|
9
|
+
var smCrypto__default = /*#__PURE__*/_interopDefault(smCrypto);
|
|
10
|
+
|
|
11
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
12
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
13
|
+
}) : x)(function(x) {
|
|
14
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
15
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// src/mask/maskOptions.ts
|
|
19
|
+
function maskByKeepEnds(value, defaults, options = {}) {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21
|
+
const start = normalizeCount(
|
|
22
|
+
(_b = (_a = options.start) != null ? _a : defaults.start) != null ? _b : 0
|
|
23
|
+
);
|
|
24
|
+
const end = normalizeCount(
|
|
25
|
+
(_d = (_c = options.end) != null ? _c : defaults.end) != null ? _d : 0
|
|
26
|
+
);
|
|
27
|
+
const maskChar = options.maskChar || defaults.maskChar || "*";
|
|
28
|
+
if (value.length <= start + end) {
|
|
29
|
+
const hiddenLength2 = Math.max(
|
|
30
|
+
value.length - start,
|
|
31
|
+
0
|
|
32
|
+
);
|
|
33
|
+
const maskLength2 = normalizeCount(
|
|
34
|
+
(_f = (_e = options.maskLength) != null ? _e : defaults.maskLength) != null ? _f : hiddenLength2
|
|
35
|
+
);
|
|
36
|
+
return value.slice(0, start) + maskChar.repeat(maskLength2);
|
|
37
|
+
}
|
|
38
|
+
const hiddenLength = Math.max(
|
|
39
|
+
value.length - start - end,
|
|
40
|
+
0
|
|
41
|
+
);
|
|
42
|
+
const maskLength = normalizeCount(
|
|
43
|
+
(_h = (_g = options.maskLength) != null ? _g : defaults.maskLength) != null ? _h : hiddenLength
|
|
44
|
+
);
|
|
45
|
+
return value.slice(0, start) + maskChar.repeat(maskLength) + (end > 0 ? value.slice(-end) : "");
|
|
46
|
+
}
|
|
47
|
+
function normalizeCount(value) {
|
|
48
|
+
return Math.max(0, Math.floor(value));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// src/mask/mask.ts
|
|
52
|
+
function mask(value, options = {}) {
|
|
53
|
+
if (!value) return "";
|
|
54
|
+
if (options.pattern) {
|
|
55
|
+
return maskByPattern(value, options);
|
|
56
|
+
}
|
|
57
|
+
if (options.range) {
|
|
58
|
+
return maskByRange(value, options);
|
|
59
|
+
}
|
|
60
|
+
return maskByKeepEnds(value, {}, options);
|
|
61
|
+
}
|
|
62
|
+
function maskByPattern(value, options) {
|
|
63
|
+
const {
|
|
64
|
+
pattern,
|
|
65
|
+
replacement,
|
|
66
|
+
maskChar = "*"
|
|
67
|
+
} = options;
|
|
68
|
+
if (!pattern) return value;
|
|
69
|
+
return value.replace(pattern, (match) => {
|
|
70
|
+
if (typeof replacement === "function") {
|
|
71
|
+
return replacement(match);
|
|
72
|
+
}
|
|
73
|
+
if (typeof replacement === "string") {
|
|
74
|
+
return replacement;
|
|
75
|
+
}
|
|
76
|
+
return maskChar.repeat(
|
|
77
|
+
getMaskLength(match.length, options)
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function maskByRange(value, options) {
|
|
82
|
+
const [rawStart, rawEnd] = options.range || [0, 0];
|
|
83
|
+
const start = clampIndex(rawStart, value.length);
|
|
84
|
+
const end = clampIndex(rawEnd, value.length);
|
|
85
|
+
const from = Math.min(start, end);
|
|
86
|
+
const to = Math.max(start, end);
|
|
87
|
+
const maskChar = options.maskChar || "*";
|
|
88
|
+
return value.slice(0, from) + maskChar.repeat(
|
|
89
|
+
getMaskLength(to - from, options)
|
|
90
|
+
) + value.slice(to);
|
|
91
|
+
}
|
|
92
|
+
function getMaskLength(hiddenLength, options) {
|
|
93
|
+
var _a;
|
|
94
|
+
return Math.max(
|
|
95
|
+
0,
|
|
96
|
+
Math.floor(
|
|
97
|
+
(_a = options.maskLength) != null ? _a : hiddenLength
|
|
98
|
+
)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
function clampIndex(value, length) {
|
|
102
|
+
return Math.min(
|
|
103
|
+
Math.max(0, Math.floor(value)),
|
|
104
|
+
length
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/mask/maskName.ts
|
|
109
|
+
function maskName(name, options) {
|
|
110
|
+
if (!name) return "";
|
|
111
|
+
return maskByKeepEnds(
|
|
112
|
+
name,
|
|
113
|
+
{
|
|
114
|
+
start: 1,
|
|
115
|
+
end: 1,
|
|
116
|
+
maskChar: "*"
|
|
117
|
+
},
|
|
118
|
+
options
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/mask/maskPhone.ts
|
|
123
|
+
function maskPhone(phone, options) {
|
|
124
|
+
if (!phone) return "";
|
|
125
|
+
if (!/^\d{11}$/.test(phone)) return phone;
|
|
126
|
+
return maskByKeepEnds(
|
|
127
|
+
phone,
|
|
128
|
+
{
|
|
129
|
+
start: 3,
|
|
130
|
+
end: 4,
|
|
131
|
+
maskChar: "*",
|
|
132
|
+
maskLength: 4
|
|
133
|
+
},
|
|
134
|
+
options
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// src/mask/maskFixedPhone.ts
|
|
139
|
+
function maskFixedPhone(phone, options) {
|
|
140
|
+
if (!phone) return "";
|
|
141
|
+
const normalized = phone.replace(/[\s-]/g, "");
|
|
142
|
+
if (!/^\d{10,12}$/.test(normalized)) {
|
|
143
|
+
return phone;
|
|
144
|
+
}
|
|
145
|
+
const areaCodeLength = getAreaCodeLength(
|
|
146
|
+
phone,
|
|
147
|
+
normalized
|
|
148
|
+
);
|
|
149
|
+
return maskByKeepEnds(
|
|
150
|
+
normalized,
|
|
151
|
+
{
|
|
152
|
+
start: areaCodeLength,
|
|
153
|
+
end: 4,
|
|
154
|
+
maskChar: "*"
|
|
155
|
+
},
|
|
156
|
+
options
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
function getAreaCodeLength(phone, normalized) {
|
|
160
|
+
const areaCodeMatch = phone.match(/^(\d{3,4})-/);
|
|
161
|
+
if (areaCodeMatch) {
|
|
162
|
+
return areaCodeMatch[1].length;
|
|
163
|
+
}
|
|
164
|
+
if (normalized.length === 10) {
|
|
165
|
+
return 3;
|
|
166
|
+
}
|
|
167
|
+
return isThreeDigitAreaCode(normalized) ? 3 : 4;
|
|
168
|
+
}
|
|
169
|
+
function isThreeDigitAreaCode(value) {
|
|
170
|
+
return /^(010|020|021|022|023|024|025|027|028|029)/.test(
|
|
171
|
+
value
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/mask/maskEmail.ts
|
|
176
|
+
function maskEmail(email, options) {
|
|
177
|
+
if (!email) return "";
|
|
178
|
+
const [name, domain] = email.split("@");
|
|
179
|
+
if (!name || !domain) return email;
|
|
180
|
+
const masked = maskByKeepEnds(
|
|
181
|
+
name,
|
|
182
|
+
{
|
|
183
|
+
start: 2,
|
|
184
|
+
end: 0,
|
|
185
|
+
maskChar: "*",
|
|
186
|
+
maskLength: 4
|
|
187
|
+
},
|
|
188
|
+
options
|
|
189
|
+
);
|
|
190
|
+
return `${masked}@${domain}`;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/mask/maskIdCard.ts
|
|
194
|
+
function maskIdCard(idCard, options) {
|
|
195
|
+
if (!idCard) return "";
|
|
196
|
+
if (idCard.length <= 8) return idCard;
|
|
197
|
+
return maskByKeepEnds(
|
|
198
|
+
idCard,
|
|
199
|
+
{
|
|
200
|
+
start: 4,
|
|
201
|
+
end: 4,
|
|
202
|
+
maskChar: "*",
|
|
203
|
+
maskLength: 10
|
|
204
|
+
},
|
|
205
|
+
options
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// src/mask/maskBankCard.ts
|
|
210
|
+
function maskBankCard(cardNo, options) {
|
|
211
|
+
if (!cardNo) return "";
|
|
212
|
+
const normalized = cardNo.replace(/[\s-]/g, "");
|
|
213
|
+
if (!/^\d{10,30}$/.test(normalized)) {
|
|
214
|
+
return cardNo;
|
|
215
|
+
}
|
|
216
|
+
return maskByKeepEnds(
|
|
217
|
+
normalized,
|
|
218
|
+
{
|
|
219
|
+
start: 6,
|
|
220
|
+
end: 4,
|
|
221
|
+
maskChar: "*"
|
|
222
|
+
},
|
|
223
|
+
options
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// src/mask/maskAddress.ts
|
|
228
|
+
function maskAddress(address, options = {}) {
|
|
229
|
+
var _a, _b;
|
|
230
|
+
if (!address) return "";
|
|
231
|
+
const keepLength = (_a = options.keepLength) != null ? _a : getRegionEndIndex(address);
|
|
232
|
+
const maskChar = options.maskChar || "*";
|
|
233
|
+
const maskLength = Math.max(
|
|
234
|
+
0,
|
|
235
|
+
Math.floor((_b = options.maskLength) != null ? _b : 4)
|
|
236
|
+
);
|
|
237
|
+
return address.slice(0, keepLength) + maskChar.repeat(maskLength);
|
|
238
|
+
}
|
|
239
|
+
function getRegionEndIndex(address) {
|
|
240
|
+
const regionMatch = address.match(
|
|
241
|
+
/^(.+?(省|自治区|特别行政区))?(.+?(市|自治州|地区|盟))?(.+?(区|县|自治县|旗|自治旗|市))/
|
|
242
|
+
);
|
|
243
|
+
if (regionMatch) {
|
|
244
|
+
return regionMatch[0].length;
|
|
245
|
+
}
|
|
246
|
+
return Math.min(6, address.length);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/mask/maskPassport.ts
|
|
250
|
+
function maskPassport(passport, options) {
|
|
251
|
+
if (!passport) return "";
|
|
252
|
+
return maskByKeepEnds(
|
|
253
|
+
passport,
|
|
254
|
+
{
|
|
255
|
+
start: 2,
|
|
256
|
+
end: 2,
|
|
257
|
+
maskChar: "*"
|
|
258
|
+
},
|
|
259
|
+
options
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// src/mask/maskCarPlate.ts
|
|
264
|
+
function maskCarPlate(plate, options) {
|
|
265
|
+
if (!plate) return "";
|
|
266
|
+
return maskByKeepEnds(
|
|
267
|
+
plate,
|
|
268
|
+
{
|
|
269
|
+
start: 2,
|
|
270
|
+
end: 1,
|
|
271
|
+
maskChar: "*"
|
|
272
|
+
},
|
|
273
|
+
options
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/mask/maskIp.ts
|
|
278
|
+
function maskIp(ip, options = {}) {
|
|
279
|
+
if (!ip) return "";
|
|
280
|
+
if (ip.includes(":")) {
|
|
281
|
+
return maskIpv6(ip, options);
|
|
282
|
+
}
|
|
283
|
+
return maskIpv4(ip, options);
|
|
284
|
+
}
|
|
285
|
+
function maskIpv4(ip, options) {
|
|
286
|
+
var _a;
|
|
287
|
+
const segments = ip.split(".");
|
|
288
|
+
if (segments.length !== 4 || segments.some((segment) => !isIpv4Segment(segment))) {
|
|
289
|
+
return ip;
|
|
290
|
+
}
|
|
291
|
+
const target = Math.min(
|
|
292
|
+
Math.max((_a = options.segment) != null ? _a : 3, 0),
|
|
293
|
+
3
|
|
294
|
+
);
|
|
295
|
+
segments[target] = options.maskChar || "*";
|
|
296
|
+
return segments.join(".");
|
|
297
|
+
}
|
|
298
|
+
function maskIpv6(ip, options) {
|
|
299
|
+
var _a;
|
|
300
|
+
const segments = ip.split(":");
|
|
301
|
+
if (segments.length < 3) return ip;
|
|
302
|
+
const target = Math.min(
|
|
303
|
+
Math.max(
|
|
304
|
+
(_a = options.segment) != null ? _a : segments.length - 1,
|
|
305
|
+
0
|
|
306
|
+
),
|
|
307
|
+
segments.length - 1
|
|
308
|
+
);
|
|
309
|
+
segments[target] = options.maskChar || "*";
|
|
310
|
+
return segments.join(":");
|
|
311
|
+
}
|
|
312
|
+
function isIpv4Segment(segment) {
|
|
313
|
+
if (!/^\d+$/.test(segment)) return false;
|
|
314
|
+
const value = Number(segment);
|
|
315
|
+
return value >= 0 && value <= 255;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/mask/maskAccount.ts
|
|
319
|
+
function maskAccount(account, options) {
|
|
320
|
+
if (!account) return "";
|
|
321
|
+
return maskByKeepEnds(
|
|
322
|
+
account,
|
|
323
|
+
{
|
|
324
|
+
start: 2,
|
|
325
|
+
end: 2,
|
|
326
|
+
maskChar: "*"
|
|
327
|
+
},
|
|
328
|
+
options
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// src/mask/maskSecret.ts
|
|
333
|
+
function maskSecret(secret, options) {
|
|
334
|
+
if (!secret) return "";
|
|
335
|
+
return maskByKeepEnds(
|
|
336
|
+
secret,
|
|
337
|
+
{
|
|
338
|
+
start: 4,
|
|
339
|
+
end: 4,
|
|
340
|
+
maskChar: "*",
|
|
341
|
+
maskLength: 6
|
|
342
|
+
},
|
|
343
|
+
options
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// src/regexp/index.ts
|
|
348
|
+
var REGEXP_PHONE = /^1[3-9]\d{9}$/;
|
|
349
|
+
var REGEXP_FIXED_PHONE = /^0\d{2,3}-?\d{7,8}$/;
|
|
350
|
+
var REGEXP_EMAIL = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;
|
|
351
|
+
var REGEXP_ID_CARD = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/;
|
|
352
|
+
var REGEXP_BANK_CARD = /^\d{10,30}$/;
|
|
353
|
+
var REGEXP_PASSPORT = /^([A-Za-z]\d{8}|[A-Za-z]{2}\d{7})$/;
|
|
354
|
+
var REGEXP_CAR_PLATE = /^[\u4e00-\u9fa5][A-Z][A-Z0-9]{5,6}$/;
|
|
355
|
+
var REGEXP_URL = /^https?:\/\/[^\s/$.?#].[^\s]*$/i;
|
|
356
|
+
var REGEXP_IPV4 = /^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)){3}$/;
|
|
357
|
+
var REGEXP_IPV6 = /^(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(([0-9A-Fa-f]{1,4}:){1,7}:)|(([0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,5}(:[0-9A-Fa-f]{1,4}){1,2})|(([0-9A-Fa-f]{1,4}:){1,4}(:[0-9A-Fa-f]{1,4}){1,3})|(([0-9A-Fa-f]{1,4}:){1,3}(:[0-9A-Fa-f]{1,4}){1,4})|(([0-9A-Fa-f]{1,4}:){1,2}(:[0-9A-Fa-f]{1,4}){1,5})|([0-9A-Fa-f]{1,4}:)((:[0-9A-Fa-f]{1,4}){1,6})|:(:([0-9A-Fa-f]{1,4}){1,7}|:))$/;
|
|
358
|
+
var REGEXP_PORT = /^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/;
|
|
359
|
+
var REGEXP_CHINESE = /^[\u4e00-\u9fa5]+$/;
|
|
360
|
+
var REGEXP_POSTAL_CODE = /^[1-9]\d{5}$/;
|
|
361
|
+
var REGEXP_QQ = /^[1-9]\d{4,10}$/;
|
|
362
|
+
var REGEXP_USERNAME = /^[A-Za-z][A-Za-z0-9_]{3,19}$/;
|
|
363
|
+
var REGEXP_PASSWORD = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d\S]{8,20}$/;
|
|
364
|
+
var REGEXP_STRONG_PASSWORD = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\w\s]).{8,20}$/;
|
|
365
|
+
var REGEXP_INTEGER = /^-?\d+$/;
|
|
366
|
+
var REGEXP_POSITIVE_INTEGER = /^[1-9]\d*$/;
|
|
367
|
+
var REGEXP_DECIMAL = /^-?(0|[1-9]\d*)(\.\d+)?$/;
|
|
368
|
+
var REGEXP_AMOUNT = /^(0|[1-9]\d*)(\.\d{1,2})?$/;
|
|
369
|
+
var regexp = {
|
|
370
|
+
phone: REGEXP_PHONE,
|
|
371
|
+
fixedPhone: REGEXP_FIXED_PHONE,
|
|
372
|
+
email: REGEXP_EMAIL,
|
|
373
|
+
idCard: REGEXP_ID_CARD,
|
|
374
|
+
bankCard: REGEXP_BANK_CARD,
|
|
375
|
+
passport: REGEXP_PASSPORT,
|
|
376
|
+
carPlate: REGEXP_CAR_PLATE,
|
|
377
|
+
url: REGEXP_URL,
|
|
378
|
+
ipv4: REGEXP_IPV4,
|
|
379
|
+
ipv6: REGEXP_IPV6,
|
|
380
|
+
port: REGEXP_PORT,
|
|
381
|
+
chinese: REGEXP_CHINESE,
|
|
382
|
+
postalCode: REGEXP_POSTAL_CODE,
|
|
383
|
+
qq: REGEXP_QQ,
|
|
384
|
+
username: REGEXP_USERNAME,
|
|
385
|
+
password: REGEXP_PASSWORD,
|
|
386
|
+
strongPassword: REGEXP_STRONG_PASSWORD,
|
|
387
|
+
integer: REGEXP_INTEGER,
|
|
388
|
+
positiveInteger: REGEXP_POSITIVE_INTEGER,
|
|
389
|
+
decimal: REGEXP_DECIMAL,
|
|
390
|
+
amount: REGEXP_AMOUNT
|
|
391
|
+
};
|
|
392
|
+
function testRegexp(value, pattern) {
|
|
393
|
+
pattern.lastIndex = 0;
|
|
394
|
+
return pattern.test(value);
|
|
395
|
+
}
|
|
396
|
+
var isPhone = (value) => testRegexp(value, REGEXP_PHONE);
|
|
397
|
+
var isFixedPhone = (value) => testRegexp(value, REGEXP_FIXED_PHONE);
|
|
398
|
+
var isEmail = (value) => testRegexp(value, REGEXP_EMAIL);
|
|
399
|
+
var isIdCard = (value) => testRegexp(value, REGEXP_ID_CARD);
|
|
400
|
+
var isBankCard = (value) => testRegexp(value, REGEXP_BANK_CARD);
|
|
401
|
+
var isPassport = (value) => testRegexp(value, REGEXP_PASSPORT);
|
|
402
|
+
var isCarPlate = (value) => testRegexp(value, REGEXP_CAR_PLATE);
|
|
403
|
+
var isUrl = (value) => testRegexp(value, REGEXP_URL);
|
|
404
|
+
var isIpv4 = (value) => testRegexp(value, REGEXP_IPV4);
|
|
405
|
+
var isIpv6 = (value) => testRegexp(value, REGEXP_IPV6);
|
|
406
|
+
var isPort = (value) => testRegexp(value, REGEXP_PORT);
|
|
407
|
+
var isChinese = (value) => testRegexp(value, REGEXP_CHINESE);
|
|
408
|
+
var isPostalCode = (value) => testRegexp(value, REGEXP_POSTAL_CODE);
|
|
409
|
+
var isQq = (value) => testRegexp(value, REGEXP_QQ);
|
|
410
|
+
var isUsername = (value) => testRegexp(value, REGEXP_USERNAME);
|
|
411
|
+
var isPassword = (value) => testRegexp(value, REGEXP_PASSWORD);
|
|
412
|
+
var isStrongPassword = (value) => testRegexp(value, REGEXP_STRONG_PASSWORD);
|
|
413
|
+
var isInteger = (value) => testRegexp(value, REGEXP_INTEGER);
|
|
414
|
+
var isPositiveInteger = (value) => testRegexp(value, REGEXP_POSITIVE_INTEGER);
|
|
415
|
+
var isDecimal = (value) => testRegexp(value, REGEXP_DECIMAL);
|
|
416
|
+
var isAmount = (value) => testRegexp(value, REGEXP_AMOUNT);
|
|
417
|
+
|
|
418
|
+
// src/cache/index.ts
|
|
419
|
+
function createCache(options = {}) {
|
|
420
|
+
var _a;
|
|
421
|
+
const prefix = (_a = options.prefix) != null ? _a : "szkj:cache:";
|
|
422
|
+
const memory = /* @__PURE__ */ new Map();
|
|
423
|
+
const resolveKey = (key) => `${prefix}${key}`;
|
|
424
|
+
const unresolveKey = (key) => key.startsWith(prefix) ? key.slice(prefix.length) : key;
|
|
425
|
+
const getExpiresAt = (ttl = options.ttl) => {
|
|
426
|
+
if (typeof ttl !== "number") return null;
|
|
427
|
+
return Date.now() + Math.max(0, ttl);
|
|
428
|
+
};
|
|
429
|
+
const read = (resolvedKey) => {
|
|
430
|
+
if (!options.storage) {
|
|
431
|
+
return memory.get(resolvedKey);
|
|
432
|
+
}
|
|
433
|
+
const raw = options.storage.getItem(resolvedKey);
|
|
434
|
+
if (!raw) return void 0;
|
|
435
|
+
try {
|
|
436
|
+
return JSON.parse(raw);
|
|
437
|
+
} catch {
|
|
438
|
+
options.storage.removeItem(resolvedKey);
|
|
439
|
+
return void 0;
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
const write = (resolvedKey, record) => {
|
|
443
|
+
if (!options.storage) {
|
|
444
|
+
memory.set(resolvedKey, record);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
options.storage.setItem(
|
|
448
|
+
resolvedKey,
|
|
449
|
+
JSON.stringify(record)
|
|
450
|
+
);
|
|
451
|
+
};
|
|
452
|
+
const removeResolved = (resolvedKey) => {
|
|
453
|
+
if (!options.storage) {
|
|
454
|
+
memory.delete(resolvedKey);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
options.storage.removeItem(resolvedKey);
|
|
458
|
+
};
|
|
459
|
+
const isExpired = (record) => typeof record.expiresAt === "number" && record.expiresAt <= Date.now();
|
|
460
|
+
const getResolvedKeys = () => {
|
|
461
|
+
if (!options.storage) {
|
|
462
|
+
return Array.from(memory.keys()).filter(
|
|
463
|
+
(key) => key.startsWith(prefix)
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
const keys2 = [];
|
|
467
|
+
for (let index = 0; index < options.storage.length; index += 1) {
|
|
468
|
+
const key = options.storage.key(index);
|
|
469
|
+
if (key == null ? void 0 : key.startsWith(prefix)) {
|
|
470
|
+
keys2.push(key);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return keys2;
|
|
474
|
+
};
|
|
475
|
+
const get2 = (key) => {
|
|
476
|
+
const resolvedKey = resolveKey(key);
|
|
477
|
+
const record = read(resolvedKey);
|
|
478
|
+
if (!record) return void 0;
|
|
479
|
+
if (isExpired(record)) {
|
|
480
|
+
removeResolved(resolvedKey);
|
|
481
|
+
return void 0;
|
|
482
|
+
}
|
|
483
|
+
return record.value;
|
|
484
|
+
};
|
|
485
|
+
const keys = () => getResolvedKeys().reduce((result, key) => {
|
|
486
|
+
const record = read(key);
|
|
487
|
+
if (!record || isExpired(record)) {
|
|
488
|
+
removeResolved(key);
|
|
489
|
+
return result;
|
|
490
|
+
}
|
|
491
|
+
result.push(unresolveKey(key));
|
|
492
|
+
return result;
|
|
493
|
+
}, []);
|
|
494
|
+
return {
|
|
495
|
+
set(key, value, setOptions = {}) {
|
|
496
|
+
write(resolveKey(key), {
|
|
497
|
+
value,
|
|
498
|
+
expiresAt: getExpiresAt(setOptions.ttl)
|
|
499
|
+
});
|
|
500
|
+
},
|
|
501
|
+
get: get2,
|
|
502
|
+
has(key) {
|
|
503
|
+
return get2(key) !== void 0;
|
|
504
|
+
},
|
|
505
|
+
remove(key) {
|
|
506
|
+
removeResolved(resolveKey(key));
|
|
507
|
+
},
|
|
508
|
+
clear() {
|
|
509
|
+
getResolvedKeys().forEach(removeResolved);
|
|
510
|
+
},
|
|
511
|
+
keys,
|
|
512
|
+
size() {
|
|
513
|
+
return keys().length;
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
var cache = createCache();
|
|
518
|
+
var { sm2, sm4 } = smCrypto__default.default;
|
|
519
|
+
function createCrypto(options = {}) {
|
|
520
|
+
return {
|
|
521
|
+
encrypt(value, secret) {
|
|
522
|
+
return encrypt(
|
|
523
|
+
value,
|
|
524
|
+
getRequiredKey(secret != null ? secret : options.aesKey, "AES key"),
|
|
525
|
+
options.aesOptions
|
|
526
|
+
);
|
|
527
|
+
},
|
|
528
|
+
decrypt(value, secret) {
|
|
529
|
+
return decrypt(
|
|
530
|
+
value,
|
|
531
|
+
getRequiredKey(secret != null ? secret : options.aesKey, "AES key"),
|
|
532
|
+
options.aesOptions
|
|
533
|
+
);
|
|
534
|
+
},
|
|
535
|
+
encryptAes(value, secret) {
|
|
536
|
+
return encryptAes(
|
|
537
|
+
value,
|
|
538
|
+
getRequiredKey(secret != null ? secret : options.aesKey, "AES key"),
|
|
539
|
+
options.aesOptions
|
|
540
|
+
);
|
|
541
|
+
},
|
|
542
|
+
decryptAes(value, secret) {
|
|
543
|
+
return decryptAes(
|
|
544
|
+
value,
|
|
545
|
+
getRequiredKey(secret != null ? secret : options.aesKey, "AES key"),
|
|
546
|
+
options.aesOptions
|
|
547
|
+
);
|
|
548
|
+
},
|
|
549
|
+
encryptRsa(value, publicKey) {
|
|
550
|
+
return encryptRsa(
|
|
551
|
+
value,
|
|
552
|
+
getRequiredKey(
|
|
553
|
+
publicKey != null ? publicKey : options.rsaPublicKey,
|
|
554
|
+
"RSA public key"
|
|
555
|
+
)
|
|
556
|
+
);
|
|
557
|
+
},
|
|
558
|
+
decryptRsa(value, privateKey) {
|
|
559
|
+
return decryptRsa(
|
|
560
|
+
value,
|
|
561
|
+
getRequiredKey(
|
|
562
|
+
privateKey != null ? privateKey : options.rsaPrivateKey,
|
|
563
|
+
"RSA private key"
|
|
564
|
+
)
|
|
565
|
+
);
|
|
566
|
+
},
|
|
567
|
+
encryptSm2(value, publicKey) {
|
|
568
|
+
return encryptSm2(
|
|
569
|
+
value,
|
|
570
|
+
getRequiredKey(
|
|
571
|
+
publicKey != null ? publicKey : options.sm2PublicKey,
|
|
572
|
+
"SM2 public key"
|
|
573
|
+
),
|
|
574
|
+
options.sm2Options
|
|
575
|
+
);
|
|
576
|
+
},
|
|
577
|
+
decryptSm2(value, privateKey) {
|
|
578
|
+
return decryptSm2(
|
|
579
|
+
value,
|
|
580
|
+
getRequiredKey(
|
|
581
|
+
privateKey != null ? privateKey : options.sm2PrivateKey,
|
|
582
|
+
"SM2 private key"
|
|
583
|
+
),
|
|
584
|
+
options.sm2Options
|
|
585
|
+
);
|
|
586
|
+
},
|
|
587
|
+
encryptSm4(value, key) {
|
|
588
|
+
return encryptSm4(
|
|
589
|
+
value,
|
|
590
|
+
getRequiredKey(key != null ? key : options.sm4Key, "SM4 key"),
|
|
591
|
+
options.sm4Options
|
|
592
|
+
);
|
|
593
|
+
},
|
|
594
|
+
decryptSm4(value, key) {
|
|
595
|
+
return decryptSm4(
|
|
596
|
+
value,
|
|
597
|
+
getRequiredKey(key != null ? key : options.sm4Key, "SM4 key"),
|
|
598
|
+
options.sm4Options
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function encrypt(value, secret, options) {
|
|
604
|
+
return encryptAes(value, secret, options);
|
|
605
|
+
}
|
|
606
|
+
function decrypt(value, secret, options) {
|
|
607
|
+
return decryptAes(value, secret, options);
|
|
608
|
+
}
|
|
609
|
+
function encryptAes(value, secret, options) {
|
|
610
|
+
return CryptoJS__default.default.AES.encrypt(
|
|
611
|
+
value,
|
|
612
|
+
getAesKey(secret, options),
|
|
613
|
+
getAesOptions(options)
|
|
614
|
+
).toString();
|
|
615
|
+
}
|
|
616
|
+
function decryptAes(value, secret, options) {
|
|
617
|
+
return CryptoJS__default.default.AES.decrypt(
|
|
618
|
+
value,
|
|
619
|
+
getAesKey(secret, options),
|
|
620
|
+
getAesOptions(options)
|
|
621
|
+
).toString(CryptoJS__default.default.enc.Utf8);
|
|
622
|
+
}
|
|
623
|
+
function encryptRsa(value, publicKey) {
|
|
624
|
+
const rsa = createRsa({
|
|
625
|
+
publicKey
|
|
626
|
+
});
|
|
627
|
+
const encrypted = rsa.encryptLong(value);
|
|
628
|
+
if (!encrypted) {
|
|
629
|
+
throw new Error("RSA encrypt failed");
|
|
630
|
+
}
|
|
631
|
+
return encrypted;
|
|
632
|
+
}
|
|
633
|
+
function decryptRsa(value, privateKey) {
|
|
634
|
+
const rsa = createRsa({
|
|
635
|
+
privateKey
|
|
636
|
+
});
|
|
637
|
+
const decrypted = rsa.decryptLong(value);
|
|
638
|
+
if (!decrypted) {
|
|
639
|
+
throw new Error("RSA decrypt failed");
|
|
640
|
+
}
|
|
641
|
+
return decrypted;
|
|
642
|
+
}
|
|
643
|
+
function encryptSm2(value, publicKey, options = {}) {
|
|
644
|
+
var _a;
|
|
645
|
+
return sm2.doEncrypt(
|
|
646
|
+
value,
|
|
647
|
+
publicKey,
|
|
648
|
+
(_a = options.cipherMode) != null ? _a : 1
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
function decryptSm2(value, privateKey, options = {}) {
|
|
652
|
+
var _a;
|
|
653
|
+
return sm2.doDecrypt(
|
|
654
|
+
value,
|
|
655
|
+
privateKey,
|
|
656
|
+
(_a = options.cipherMode) != null ? _a : 1
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
function encryptSm4(value, key, options = {}) {
|
|
660
|
+
return sm4.encrypt(value, key, options);
|
|
661
|
+
}
|
|
662
|
+
function decryptSm4(value, key, options = {}) {
|
|
663
|
+
return sm4.decrypt(value, key, options);
|
|
664
|
+
}
|
|
665
|
+
function md5(value) {
|
|
666
|
+
return CryptoJS__default.default.MD5(value).toString();
|
|
667
|
+
}
|
|
668
|
+
function sha256(value) {
|
|
669
|
+
return CryptoJS__default.default.SHA256(value).toString();
|
|
670
|
+
}
|
|
671
|
+
function toBase64(value) {
|
|
672
|
+
return CryptoJS__default.default.enc.Base64.stringify(
|
|
673
|
+
CryptoJS__default.default.enc.Utf8.parse(value)
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
function fromBase64(value) {
|
|
677
|
+
return CryptoJS__default.default.enc.Base64.parse(value).toString(
|
|
678
|
+
CryptoJS__default.default.enc.Utf8
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
function getAesKey(secret, options) {
|
|
682
|
+
if ((options == null ? void 0 : options.keyMode) === "passphrase") {
|
|
683
|
+
return secret;
|
|
684
|
+
}
|
|
685
|
+
return CryptoJS__default.default.enc.Utf8.parse(secret);
|
|
686
|
+
}
|
|
687
|
+
function getAesOptions(options) {
|
|
688
|
+
var _a, _b;
|
|
689
|
+
if ((options == null ? void 0 : options.keyMode) === "passphrase") {
|
|
690
|
+
return {};
|
|
691
|
+
}
|
|
692
|
+
const aesOptions = {
|
|
693
|
+
mode: CryptoJS__default.default.mode[(_a = options == null ? void 0 : options.mode) != null ? _a : "ECB"],
|
|
694
|
+
padding: CryptoJS__default.default.pad[(_b = options == null ? void 0 : options.padding) != null ? _b : "Pkcs7"]
|
|
695
|
+
};
|
|
696
|
+
if (options == null ? void 0 : options.iv) {
|
|
697
|
+
aesOptions.iv = CryptoJS__default.default.enc.Utf8.parse(options.iv);
|
|
698
|
+
}
|
|
699
|
+
return aesOptions;
|
|
700
|
+
}
|
|
701
|
+
function createRsa(options) {
|
|
702
|
+
const EncryptLong = getEncryptLong();
|
|
703
|
+
const rsa = new EncryptLong();
|
|
704
|
+
if (options.publicKey) {
|
|
705
|
+
rsa.setPublicKey(options.publicKey);
|
|
706
|
+
}
|
|
707
|
+
if (options.privateKey) {
|
|
708
|
+
rsa.setPrivateKey(options.privateKey);
|
|
709
|
+
}
|
|
710
|
+
return rsa;
|
|
711
|
+
}
|
|
712
|
+
function getEncryptLong() {
|
|
713
|
+
if (typeof window === "undefined") {
|
|
714
|
+
throw new Error("RSA is only available in browser environments");
|
|
715
|
+
}
|
|
716
|
+
const requireFn = getRequire();
|
|
717
|
+
if (!requireFn) {
|
|
718
|
+
throw new Error("RSA is only available in CommonJS-compatible environments");
|
|
719
|
+
}
|
|
720
|
+
const module = requireFn("encryptlong");
|
|
721
|
+
return "default" in module ? module.default : module;
|
|
722
|
+
}
|
|
723
|
+
function getRequire() {
|
|
724
|
+
return typeof __require === "function" ? __require : void 0;
|
|
725
|
+
}
|
|
726
|
+
function getRequiredKey(key, name) {
|
|
727
|
+
if (!key) {
|
|
728
|
+
throw new Error(`${name} is required`);
|
|
729
|
+
}
|
|
730
|
+
return key;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// src/date/index.ts
|
|
734
|
+
function toDate(value) {
|
|
735
|
+
if (value instanceof Date) {
|
|
736
|
+
return new Date(value.getTime());
|
|
737
|
+
}
|
|
738
|
+
return new Date(value);
|
|
739
|
+
}
|
|
740
|
+
function isValidDate(value) {
|
|
741
|
+
return !Number.isNaN(toDate(value).getTime());
|
|
742
|
+
}
|
|
743
|
+
function formatDate(value, pattern = "YYYY-MM-DD HH:mm:ss") {
|
|
744
|
+
const date = toDate(value);
|
|
745
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
746
|
+
const tokens = {
|
|
747
|
+
YYYY: String(date.getFullYear()),
|
|
748
|
+
YY: String(date.getFullYear()).slice(-2),
|
|
749
|
+
MM: pad(date.getMonth() + 1),
|
|
750
|
+
M: String(date.getMonth() + 1),
|
|
751
|
+
DD: pad(date.getDate()),
|
|
752
|
+
D: String(date.getDate()),
|
|
753
|
+
HH: pad(date.getHours()),
|
|
754
|
+
H: String(date.getHours()),
|
|
755
|
+
mm: pad(date.getMinutes()),
|
|
756
|
+
m: String(date.getMinutes()),
|
|
757
|
+
ss: pad(date.getSeconds()),
|
|
758
|
+
s: String(date.getSeconds()),
|
|
759
|
+
SSS: pad(date.getMilliseconds(), 3)
|
|
760
|
+
};
|
|
761
|
+
return pattern.replace(
|
|
762
|
+
/YYYY|YY|SSS|MM|M|DD|D|HH|H|mm|m|ss|s/g,
|
|
763
|
+
(token) => tokens[token]
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
function startOfDay(value) {
|
|
767
|
+
const date = toDate(value);
|
|
768
|
+
date.setHours(0, 0, 0, 0);
|
|
769
|
+
return date;
|
|
770
|
+
}
|
|
771
|
+
function endOfDay(value) {
|
|
772
|
+
const date = toDate(value);
|
|
773
|
+
date.setHours(23, 59, 59, 999);
|
|
774
|
+
return date;
|
|
775
|
+
}
|
|
776
|
+
function addDays(value, amount) {
|
|
777
|
+
const date = toDate(value);
|
|
778
|
+
date.setDate(date.getDate() + amount);
|
|
779
|
+
return date;
|
|
780
|
+
}
|
|
781
|
+
function diffDays(left, right) {
|
|
782
|
+
return Math.trunc(
|
|
783
|
+
(toDate(left).getTime() - toDate(right).getTime()) / 864e5
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
function diffHours(left, right) {
|
|
787
|
+
return Math.trunc(
|
|
788
|
+
(toDate(left).getTime() - toDate(right).getTime()) / 36e5
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
function fromNow(value, now = /* @__PURE__ */ new Date()) {
|
|
792
|
+
const diff = toDate(value).getTime() - toDate(now).getTime();
|
|
793
|
+
const absDiff = Math.abs(diff);
|
|
794
|
+
const suffix = diff >= 0 ? "\u540E" : "\u524D";
|
|
795
|
+
if (absDiff < 6e4) return "\u521A\u521A";
|
|
796
|
+
const units = [
|
|
797
|
+
["\u5E74", 31536e6],
|
|
798
|
+
["\u4E2A\u6708", 2592e6],
|
|
799
|
+
["\u5929", 864e5],
|
|
800
|
+
["\u5C0F\u65F6", 36e5],
|
|
801
|
+
["\u5206\u949F", 6e4]
|
|
802
|
+
];
|
|
803
|
+
const unit = units.find(([, size]) => absDiff >= size);
|
|
804
|
+
if (!unit) return "\u521A\u521A";
|
|
805
|
+
return `${Math.floor(absDiff / unit[1])}${unit[0]}${suffix}`;
|
|
806
|
+
}
|
|
807
|
+
function pad(value, length = 2) {
|
|
808
|
+
return String(value).padStart(length, "0");
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// src/number/index.ts
|
|
812
|
+
function toFixedSafe(value, precision = 2) {
|
|
813
|
+
const scale = 10 ** precision;
|
|
814
|
+
const rounded = Math.round((value + Number.EPSILON) * scale) / scale;
|
|
815
|
+
return rounded.toFixed(precision);
|
|
816
|
+
}
|
|
817
|
+
function formatThousands(value, separator = ",") {
|
|
818
|
+
const [integer, decimal] = String(value).split(".");
|
|
819
|
+
const sign = integer.startsWith("-") ? "-" : "";
|
|
820
|
+
const normalized = sign ? integer.slice(1) : integer;
|
|
821
|
+
const formatted = normalized.replace(
|
|
822
|
+
/\B(?=(\d{3})+(?!\d))/g,
|
|
823
|
+
separator
|
|
824
|
+
);
|
|
825
|
+
return `${sign}${formatted}${decimal ? `.${decimal}` : ""}`;
|
|
826
|
+
}
|
|
827
|
+
function formatMoney(value, options = {}) {
|
|
828
|
+
const {
|
|
829
|
+
precision = 2,
|
|
830
|
+
symbol = "\xA5",
|
|
831
|
+
thousand = ",",
|
|
832
|
+
decimal = "."
|
|
833
|
+
} = options;
|
|
834
|
+
const fixed = toFixedSafe(value, precision);
|
|
835
|
+
const formatted = formatThousands(fixed, thousand);
|
|
836
|
+
return `${symbol}${formatted.replace(".", decimal)}`;
|
|
837
|
+
}
|
|
838
|
+
function formatPercent(value, options = {}) {
|
|
839
|
+
const {
|
|
840
|
+
precision = 2,
|
|
841
|
+
multiplier = 100
|
|
842
|
+
} = options;
|
|
843
|
+
return `${toFixedSafe(value * multiplier, precision)}%`;
|
|
844
|
+
}
|
|
845
|
+
function formatFileSize(bytes, precision = 2) {
|
|
846
|
+
if (!Number.isFinite(bytes)) return "";
|
|
847
|
+
if (bytes <= 0) return "0 B";
|
|
848
|
+
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
849
|
+
const index = Math.min(
|
|
850
|
+
Math.floor(Math.log(bytes) / Math.log(1024)),
|
|
851
|
+
units.length - 1
|
|
852
|
+
);
|
|
853
|
+
const value = bytes / 1024 ** index;
|
|
854
|
+
return `${toFixedSafe(value, index === 0 ? 0 : precision)} ${units[index]}`;
|
|
855
|
+
}
|
|
856
|
+
function clamp(value, min, max) {
|
|
857
|
+
return Math.min(Math.max(value, min), max);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
// src/tree/index.ts
|
|
861
|
+
var defaultTreeOptions = {
|
|
862
|
+
idKey: "id",
|
|
863
|
+
parentKey: "parentId",
|
|
864
|
+
childrenKey: "children"
|
|
865
|
+
};
|
|
866
|
+
function listToTree(list, options = {}) {
|
|
867
|
+
const config = getTreeOptions(options);
|
|
868
|
+
const nodeMap = /* @__PURE__ */ new Map();
|
|
869
|
+
const roots = [];
|
|
870
|
+
list.forEach((item) => {
|
|
871
|
+
nodeMap.set(item[config.idKey], {
|
|
872
|
+
...item,
|
|
873
|
+
[config.childrenKey]: []
|
|
874
|
+
});
|
|
875
|
+
});
|
|
876
|
+
nodeMap.forEach((node) => {
|
|
877
|
+
const parentId = node[config.parentKey];
|
|
878
|
+
const parent = nodeMap.get(parentId);
|
|
879
|
+
if (parent) {
|
|
880
|
+
getChildren(parent, config.childrenKey).push(node);
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
roots.push(node);
|
|
884
|
+
});
|
|
885
|
+
return roots;
|
|
886
|
+
}
|
|
887
|
+
function treeToList(tree, options = {}) {
|
|
888
|
+
const config = getTreeOptions(options);
|
|
889
|
+
const result = [];
|
|
890
|
+
walkTree(tree, (node) => {
|
|
891
|
+
const {
|
|
892
|
+
[config.childrenKey]: _children,
|
|
893
|
+
...rest
|
|
894
|
+
} = node;
|
|
895
|
+
result.push(rest);
|
|
896
|
+
}, config.childrenKey);
|
|
897
|
+
return result;
|
|
898
|
+
}
|
|
899
|
+
function findTreeNode(tree, predicate, options = {}) {
|
|
900
|
+
const config = getTreeOptions(options);
|
|
901
|
+
for (const node of tree) {
|
|
902
|
+
if (predicate(node)) return node;
|
|
903
|
+
const found = findTreeNode(
|
|
904
|
+
getChildren(node, config.childrenKey),
|
|
905
|
+
predicate,
|
|
906
|
+
config
|
|
907
|
+
);
|
|
908
|
+
if (found) return found;
|
|
909
|
+
}
|
|
910
|
+
return void 0;
|
|
911
|
+
}
|
|
912
|
+
function filterTree(tree, predicate, options = {}) {
|
|
913
|
+
const config = getTreeOptions(options);
|
|
914
|
+
return tree.reduce((result, node) => {
|
|
915
|
+
const children = filterTree(
|
|
916
|
+
getChildren(node, config.childrenKey),
|
|
917
|
+
predicate,
|
|
918
|
+
config
|
|
919
|
+
);
|
|
920
|
+
if (predicate(node) || children.length > 0) {
|
|
921
|
+
result.push({
|
|
922
|
+
...node,
|
|
923
|
+
[config.childrenKey]: children
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
return result;
|
|
927
|
+
}, []);
|
|
928
|
+
}
|
|
929
|
+
function getTreePath(tree, predicate, options = {}) {
|
|
930
|
+
const config = getTreeOptions(options);
|
|
931
|
+
for (const node of tree) {
|
|
932
|
+
if (predicate(node)) return [node];
|
|
933
|
+
const childPath = getTreePath(
|
|
934
|
+
getChildren(node, config.childrenKey),
|
|
935
|
+
predicate,
|
|
936
|
+
config
|
|
937
|
+
);
|
|
938
|
+
if (childPath.length > 0) {
|
|
939
|
+
return [node, ...childPath];
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
return [];
|
|
943
|
+
}
|
|
944
|
+
function getTreeLeaves(tree, options = {}) {
|
|
945
|
+
const config = getTreeOptions(options);
|
|
946
|
+
const leaves = [];
|
|
947
|
+
walkTree(tree, (node) => {
|
|
948
|
+
if (getChildren(node, config.childrenKey).length === 0) {
|
|
949
|
+
leaves.push(node);
|
|
950
|
+
}
|
|
951
|
+
}, config.childrenKey);
|
|
952
|
+
return leaves;
|
|
953
|
+
}
|
|
954
|
+
function walkTree(tree, visitor, childrenKey) {
|
|
955
|
+
tree.forEach((node) => {
|
|
956
|
+
visitor(node);
|
|
957
|
+
walkTree(
|
|
958
|
+
getChildren(node, childrenKey),
|
|
959
|
+
visitor,
|
|
960
|
+
childrenKey
|
|
961
|
+
);
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
function getChildren(node, childrenKey) {
|
|
965
|
+
const children = node[childrenKey];
|
|
966
|
+
return Array.isArray(children) ? children : [];
|
|
967
|
+
}
|
|
968
|
+
function getTreeOptions(options) {
|
|
969
|
+
return {
|
|
970
|
+
...defaultTreeOptions,
|
|
971
|
+
...options
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
// src/storage/index.ts
|
|
976
|
+
var defaultNamespace = "szkj:storage:";
|
|
977
|
+
function createStorage(options = {}) {
|
|
978
|
+
var _a, _b;
|
|
979
|
+
const namespace = (_a = options.namespace) != null ? _a : defaultNamespace;
|
|
980
|
+
const storage = (_b = options.storage) != null ? _b : getDefaultStorage("localStorage");
|
|
981
|
+
const resolveKey = (key) => `${namespace}${key}`;
|
|
982
|
+
const unresolveKey = (key) => key.startsWith(namespace) ? key.slice(namespace.length) : key;
|
|
983
|
+
const getExpiresAt = (ttl = options.ttl) => {
|
|
984
|
+
if (typeof ttl !== "number") return null;
|
|
985
|
+
return Date.now() + Math.max(0, ttl);
|
|
986
|
+
};
|
|
987
|
+
const encode = (value) => options.encrypt ? options.encrypt(value) : value;
|
|
988
|
+
const decode = (value) => options.decrypt ? options.decrypt(value) : value;
|
|
989
|
+
const readRecord = (resolvedKey) => {
|
|
990
|
+
const raw = storage.getItem(resolvedKey);
|
|
991
|
+
if (!raw) return void 0;
|
|
992
|
+
try {
|
|
993
|
+
return JSON.parse(decode(raw));
|
|
994
|
+
} catch {
|
|
995
|
+
storage.removeItem(resolvedKey);
|
|
996
|
+
return void 0;
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
const removeResolved = (resolvedKey) => {
|
|
1000
|
+
storage.removeItem(resolvedKey);
|
|
1001
|
+
};
|
|
1002
|
+
const isExpired = (record) => typeof record.expiresAt === "number" && record.expiresAt <= Date.now();
|
|
1003
|
+
const getResolvedKeys = () => {
|
|
1004
|
+
const keys2 = [];
|
|
1005
|
+
for (let index = 0; index < storage.length; index += 1) {
|
|
1006
|
+
const key = storage.key(index);
|
|
1007
|
+
if (key == null ? void 0 : key.startsWith(namespace)) {
|
|
1008
|
+
keys2.push(key);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
return keys2;
|
|
1012
|
+
};
|
|
1013
|
+
const get2 = (key) => {
|
|
1014
|
+
const resolvedKey = resolveKey(key);
|
|
1015
|
+
const record = readRecord(resolvedKey);
|
|
1016
|
+
if (!record) return void 0;
|
|
1017
|
+
if (isExpired(record)) {
|
|
1018
|
+
removeResolved(resolvedKey);
|
|
1019
|
+
return void 0;
|
|
1020
|
+
}
|
|
1021
|
+
return record.value;
|
|
1022
|
+
};
|
|
1023
|
+
const keys = () => getResolvedKeys().reduce((result, key) => {
|
|
1024
|
+
const record = readRecord(key);
|
|
1025
|
+
if (!record || isExpired(record)) {
|
|
1026
|
+
removeResolved(key);
|
|
1027
|
+
return result;
|
|
1028
|
+
}
|
|
1029
|
+
result.push(unresolveKey(key));
|
|
1030
|
+
return result;
|
|
1031
|
+
}, []);
|
|
1032
|
+
return {
|
|
1033
|
+
set(key, value, setOptions = {}) {
|
|
1034
|
+
const record = {
|
|
1035
|
+
value,
|
|
1036
|
+
expiresAt: getExpiresAt(setOptions.ttl)
|
|
1037
|
+
};
|
|
1038
|
+
storage.setItem(
|
|
1039
|
+
resolveKey(key),
|
|
1040
|
+
encode(JSON.stringify(record))
|
|
1041
|
+
);
|
|
1042
|
+
},
|
|
1043
|
+
get: get2,
|
|
1044
|
+
getRaw(key) {
|
|
1045
|
+
const raw = storage.getItem(resolveKey(key));
|
|
1046
|
+
if (!raw) return void 0;
|
|
1047
|
+
return decode(raw);
|
|
1048
|
+
},
|
|
1049
|
+
has(key) {
|
|
1050
|
+
return get2(key) !== void 0;
|
|
1051
|
+
},
|
|
1052
|
+
remove(key) {
|
|
1053
|
+
removeResolved(resolveKey(key));
|
|
1054
|
+
},
|
|
1055
|
+
clear() {
|
|
1056
|
+
getResolvedKeys().forEach(removeResolved);
|
|
1057
|
+
},
|
|
1058
|
+
keys,
|
|
1059
|
+
size() {
|
|
1060
|
+
return keys().length;
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
var localStore = createStorage({
|
|
1065
|
+
storage: getDefaultStorage("localStorage")
|
|
1066
|
+
});
|
|
1067
|
+
var sessionStore = createStorage({
|
|
1068
|
+
namespace: "szkj:session:",
|
|
1069
|
+
storage: getDefaultStorage("sessionStorage")
|
|
1070
|
+
});
|
|
1071
|
+
function getDefaultStorage(type) {
|
|
1072
|
+
if (typeof globalThis !== "undefined" && type in globalThis) {
|
|
1073
|
+
const storage = globalThis[type];
|
|
1074
|
+
if (storage) return storage;
|
|
1075
|
+
}
|
|
1076
|
+
return createMemoryStorage();
|
|
1077
|
+
}
|
|
1078
|
+
function createMemoryStorage() {
|
|
1079
|
+
const store = /* @__PURE__ */ new Map();
|
|
1080
|
+
return {
|
|
1081
|
+
get length() {
|
|
1082
|
+
return store.size;
|
|
1083
|
+
},
|
|
1084
|
+
key(index) {
|
|
1085
|
+
var _a;
|
|
1086
|
+
return (_a = Array.from(store.keys())[index]) != null ? _a : null;
|
|
1087
|
+
},
|
|
1088
|
+
getItem(key) {
|
|
1089
|
+
var _a;
|
|
1090
|
+
return (_a = store.get(key)) != null ? _a : null;
|
|
1091
|
+
},
|
|
1092
|
+
setItem(key, value) {
|
|
1093
|
+
store.set(key, value);
|
|
1094
|
+
},
|
|
1095
|
+
removeItem(key) {
|
|
1096
|
+
store.delete(key);
|
|
1097
|
+
},
|
|
1098
|
+
clear() {
|
|
1099
|
+
store.clear();
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
// src/copy/index.ts
|
|
1105
|
+
async function copyText(text, options) {
|
|
1106
|
+
var _a, _b;
|
|
1107
|
+
if (typeof navigator !== "undefined" && navigator.clipboard && typeof navigator.clipboard.writeText === "function") {
|
|
1108
|
+
try {
|
|
1109
|
+
await navigator.clipboard.writeText(text);
|
|
1110
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options);
|
|
1111
|
+
return true;
|
|
1112
|
+
} catch (error) {
|
|
1113
|
+
(_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, error);
|
|
1114
|
+
return false;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
return fallbackCopyText(text, options);
|
|
1118
|
+
}
|
|
1119
|
+
function fallbackCopyText(text, options) {
|
|
1120
|
+
var _a, _b, _c;
|
|
1121
|
+
const textarea = document.createElement("textarea");
|
|
1122
|
+
textarea.value = text;
|
|
1123
|
+
textarea.style.position = "fixed";
|
|
1124
|
+
textarea.style.top = "-9999px";
|
|
1125
|
+
textarea.style.left = "-9999px";
|
|
1126
|
+
textarea.style.opacity = "0";
|
|
1127
|
+
textarea.setAttribute("readonly", "");
|
|
1128
|
+
textarea.setAttribute("aria-hidden", "true");
|
|
1129
|
+
document.body.appendChild(textarea);
|
|
1130
|
+
textarea.focus();
|
|
1131
|
+
textarea.select();
|
|
1132
|
+
let success = false;
|
|
1133
|
+
try {
|
|
1134
|
+
success = document.execCommand("copy");
|
|
1135
|
+
if (success) {
|
|
1136
|
+
(_a = options == null ? void 0 : options.onSuccess) == null ? void 0 : _a.call(options);
|
|
1137
|
+
} else {
|
|
1138
|
+
(_b = options == null ? void 0 : options.onError) == null ? void 0 : _b.call(options, new Error('execCommand("copy") returned false'));
|
|
1139
|
+
}
|
|
1140
|
+
} catch (error) {
|
|
1141
|
+
(_c = options == null ? void 0 : options.onError) == null ? void 0 : _c.call(options, error);
|
|
1142
|
+
} finally {
|
|
1143
|
+
document.body.removeChild(textarea);
|
|
1144
|
+
}
|
|
1145
|
+
return success;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// src/download/index.ts
|
|
1149
|
+
function downloadBlob(blob, options = {}) {
|
|
1150
|
+
const { filename = "download", mimeType } = options;
|
|
1151
|
+
const downloadBlob2 = mimeType ? new Blob([blob], { type: mimeType }) : blob;
|
|
1152
|
+
const url = URL.createObjectURL(downloadBlob2);
|
|
1153
|
+
triggerDownload(url, filename);
|
|
1154
|
+
URL.revokeObjectURL(url);
|
|
1155
|
+
}
|
|
1156
|
+
function downloadText(text, filename = "download.txt") {
|
|
1157
|
+
const blob = new Blob([text], { type: "text/plain;charset=utf-8" });
|
|
1158
|
+
downloadBlob(blob, { filename });
|
|
1159
|
+
}
|
|
1160
|
+
function downloadJSON(data, filename = "download.json") {
|
|
1161
|
+
const text = JSON.stringify(data, null, 2);
|
|
1162
|
+
const blob = new Blob([text], { type: "application/json;charset=utf-8" });
|
|
1163
|
+
downloadBlob(blob, { filename });
|
|
1164
|
+
}
|
|
1165
|
+
async function downloadStream(response, options = {}) {
|
|
1166
|
+
var _a;
|
|
1167
|
+
const { filename = "download", onProgress, onError } = options;
|
|
1168
|
+
try {
|
|
1169
|
+
const contentLength = response.headers.get("content-length");
|
|
1170
|
+
const total = contentLength ? parseInt(contentLength, 10) : 0;
|
|
1171
|
+
const reader = (_a = response.body) == null ? void 0 : _a.getReader();
|
|
1172
|
+
if (!reader) {
|
|
1173
|
+
throw new Error("Response body is not readable");
|
|
1174
|
+
}
|
|
1175
|
+
const chunks = [];
|
|
1176
|
+
let loaded = 0;
|
|
1177
|
+
while (true) {
|
|
1178
|
+
const { done, value } = await reader.read();
|
|
1179
|
+
if (done) break;
|
|
1180
|
+
chunks.push(value);
|
|
1181
|
+
loaded += value.length;
|
|
1182
|
+
onProgress == null ? void 0 : onProgress(loaded, total);
|
|
1183
|
+
}
|
|
1184
|
+
const blob = new Blob(chunks);
|
|
1185
|
+
downloadBlob(blob, { filename });
|
|
1186
|
+
} catch (error) {
|
|
1187
|
+
onError == null ? void 0 : onError(error);
|
|
1188
|
+
throw error;
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
function triggerDownload(url, filename) {
|
|
1192
|
+
const link = document.createElement("a");
|
|
1193
|
+
link.href = url;
|
|
1194
|
+
link.download = filename;
|
|
1195
|
+
link.style.display = "none";
|
|
1196
|
+
document.body.appendChild(link);
|
|
1197
|
+
link.click();
|
|
1198
|
+
document.body.removeChild(link);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// src/file/index.ts
|
|
1202
|
+
function fileToBase64(file) {
|
|
1203
|
+
return new Promise((resolve, reject) => {
|
|
1204
|
+
const reader = new FileReader();
|
|
1205
|
+
reader.onload = () => {
|
|
1206
|
+
var _a;
|
|
1207
|
+
const result = reader.result;
|
|
1208
|
+
const base64 = (_a = result.split(",")[1]) != null ? _a : result;
|
|
1209
|
+
resolve(base64);
|
|
1210
|
+
};
|
|
1211
|
+
reader.onerror = reject;
|
|
1212
|
+
reader.readAsDataURL(file);
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
function base64ToBlob(base64, mimeType = "application/octet-stream") {
|
|
1216
|
+
const byteCharacters = atob(base64);
|
|
1217
|
+
const byteNumbers = new Array(byteCharacters.length);
|
|
1218
|
+
for (let i = 0; i < byteCharacters.length; i++) {
|
|
1219
|
+
byteNumbers[i] = byteCharacters.charCodeAt(i);
|
|
1220
|
+
}
|
|
1221
|
+
const byteArray = new Uint8Array(byteNumbers);
|
|
1222
|
+
return new Blob([byteArray], { type: mimeType });
|
|
1223
|
+
}
|
|
1224
|
+
function getFileExtension(filename) {
|
|
1225
|
+
const lastDot = filename.lastIndexOf(".");
|
|
1226
|
+
return lastDot === -1 ? "" : filename.slice(lastDot + 1).toLowerCase();
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
// src/object/index.ts
|
|
1230
|
+
function deepClone(obj) {
|
|
1231
|
+
if (obj === null || typeof obj !== "object") {
|
|
1232
|
+
return obj;
|
|
1233
|
+
}
|
|
1234
|
+
if (obj instanceof Date) {
|
|
1235
|
+
return new Date(obj.getTime());
|
|
1236
|
+
}
|
|
1237
|
+
if (obj instanceof Array) {
|
|
1238
|
+
return obj.map((item) => deepClone(item));
|
|
1239
|
+
}
|
|
1240
|
+
if (obj instanceof Object) {
|
|
1241
|
+
const cloned = {};
|
|
1242
|
+
Object.keys(obj).forEach((key) => {
|
|
1243
|
+
cloned[key] = deepClone(obj[key]);
|
|
1244
|
+
});
|
|
1245
|
+
return cloned;
|
|
1246
|
+
}
|
|
1247
|
+
throw new Error("Unable to copy object");
|
|
1248
|
+
}
|
|
1249
|
+
function deepMerge(target, ...sources) {
|
|
1250
|
+
if (!sources.length) return target;
|
|
1251
|
+
const source = sources.shift();
|
|
1252
|
+
if (!source) return target;
|
|
1253
|
+
for (const key in source) {
|
|
1254
|
+
if (source[key] && typeof source[key] === "object" && !Array.isArray(source[key])) {
|
|
1255
|
+
if (!target[key] || typeof target[key] !== "object") {
|
|
1256
|
+
target[key] = {};
|
|
1257
|
+
}
|
|
1258
|
+
deepMerge(
|
|
1259
|
+
target[key],
|
|
1260
|
+
source[key]
|
|
1261
|
+
);
|
|
1262
|
+
} else {
|
|
1263
|
+
target[key] = source[key];
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
return deepMerge(target, ...sources);
|
|
1267
|
+
}
|
|
1268
|
+
function removeEmptyValues(obj, options = {}) {
|
|
1269
|
+
const {
|
|
1270
|
+
removeNull = true,
|
|
1271
|
+
removeUndefined = true,
|
|
1272
|
+
removeEmptyString = false,
|
|
1273
|
+
removeEmptyArray = false,
|
|
1274
|
+
removeEmptyObject = false
|
|
1275
|
+
} = options;
|
|
1276
|
+
const result = {};
|
|
1277
|
+
for (const key in obj) {
|
|
1278
|
+
const value = obj[key];
|
|
1279
|
+
if (removeUndefined && value === void 0) continue;
|
|
1280
|
+
if (removeNull && value === null) continue;
|
|
1281
|
+
if (removeEmptyString && value === "") continue;
|
|
1282
|
+
if (removeEmptyArray && Array.isArray(value) && value.length === 0) continue;
|
|
1283
|
+
if (removeEmptyObject && typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0) continue;
|
|
1284
|
+
result[key] = value;
|
|
1285
|
+
}
|
|
1286
|
+
return result;
|
|
1287
|
+
}
|
|
1288
|
+
function pick(obj, keys) {
|
|
1289
|
+
const result = {};
|
|
1290
|
+
keys.forEach((key) => {
|
|
1291
|
+
if (key in obj) {
|
|
1292
|
+
result[key] = obj[key];
|
|
1293
|
+
}
|
|
1294
|
+
});
|
|
1295
|
+
return result;
|
|
1296
|
+
}
|
|
1297
|
+
function omit(obj, keys) {
|
|
1298
|
+
const result = { ...obj };
|
|
1299
|
+
keys.forEach((key) => {
|
|
1300
|
+
delete result[key];
|
|
1301
|
+
});
|
|
1302
|
+
return result;
|
|
1303
|
+
}
|
|
1304
|
+
function flatten(obj, prefix = "", result = {}) {
|
|
1305
|
+
for (const key in obj) {
|
|
1306
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
1307
|
+
const value = obj[key];
|
|
1308
|
+
if (value && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date)) {
|
|
1309
|
+
flatten(value, newKey, result);
|
|
1310
|
+
} else {
|
|
1311
|
+
result[newKey] = value;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
return result;
|
|
1315
|
+
}
|
|
1316
|
+
function unflatten(obj) {
|
|
1317
|
+
const result = {};
|
|
1318
|
+
for (const key in obj) {
|
|
1319
|
+
const keys = key.split(".");
|
|
1320
|
+
let current = result;
|
|
1321
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
1322
|
+
const k = keys[i];
|
|
1323
|
+
if (!(k in current)) {
|
|
1324
|
+
current[k] = {};
|
|
1325
|
+
}
|
|
1326
|
+
current = current[k];
|
|
1327
|
+
}
|
|
1328
|
+
current[keys[keys.length - 1]] = obj[key];
|
|
1329
|
+
}
|
|
1330
|
+
return result;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
// src/array/index.ts
|
|
1334
|
+
function flattenArray(arr, depth = Infinity) {
|
|
1335
|
+
const result = [];
|
|
1336
|
+
for (const item of arr) {
|
|
1337
|
+
if (Array.isArray(item) && depth > 0) {
|
|
1338
|
+
result.push(...flattenArray(item, depth - 1));
|
|
1339
|
+
} else {
|
|
1340
|
+
result.push(item);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
return result;
|
|
1344
|
+
}
|
|
1345
|
+
function chunk(arr, size) {
|
|
1346
|
+
if (size <= 0) return [];
|
|
1347
|
+
const result = [];
|
|
1348
|
+
for (let i = 0; i < arr.length; i += size) {
|
|
1349
|
+
result.push(arr.slice(i, i + size));
|
|
1350
|
+
}
|
|
1351
|
+
return result;
|
|
1352
|
+
}
|
|
1353
|
+
function unique(arr) {
|
|
1354
|
+
return [...new Set(arr)];
|
|
1355
|
+
}
|
|
1356
|
+
function uniqueBy(arr, key) {
|
|
1357
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1358
|
+
return arr.filter((item) => {
|
|
1359
|
+
const value = typeof key === "function" ? key(item) : item[key];
|
|
1360
|
+
if (seen.has(value)) return false;
|
|
1361
|
+
seen.add(value);
|
|
1362
|
+
return true;
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
function groupBy(arr, key) {
|
|
1366
|
+
const result = {};
|
|
1367
|
+
arr.forEach((item) => {
|
|
1368
|
+
const value = typeof key === "function" ? key(item) : item[key];
|
|
1369
|
+
const groupKey = String(value);
|
|
1370
|
+
if (!result[groupKey]) {
|
|
1371
|
+
result[groupKey] = [];
|
|
1372
|
+
}
|
|
1373
|
+
result[groupKey].push(item);
|
|
1374
|
+
});
|
|
1375
|
+
return result;
|
|
1376
|
+
}
|
|
1377
|
+
function intersection(arr1, arr2) {
|
|
1378
|
+
const set2 = new Set(arr2);
|
|
1379
|
+
return [...new Set(arr1)].filter((item) => set2.has(item));
|
|
1380
|
+
}
|
|
1381
|
+
function difference(arr1, arr2) {
|
|
1382
|
+
const set2 = new Set(arr2);
|
|
1383
|
+
return [...new Set(arr1)].filter((item) => !set2.has(item));
|
|
1384
|
+
}
|
|
1385
|
+
function shuffle(arr) {
|
|
1386
|
+
const result = [...arr];
|
|
1387
|
+
for (let i = result.length - 1; i > 0; i--) {
|
|
1388
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
1389
|
+
[result[i], result[j]] = [result[j], result[i]];
|
|
1390
|
+
}
|
|
1391
|
+
return result;
|
|
1392
|
+
}
|
|
1393
|
+
function sortBy(arr, key, order = "asc") {
|
|
1394
|
+
const result = [...arr];
|
|
1395
|
+
return result.sort((a, b) => {
|
|
1396
|
+
const valueA = typeof key === "function" ? key(a) : a[key];
|
|
1397
|
+
const valueB = typeof key === "function" ? key(b) : b[key];
|
|
1398
|
+
if (valueA === valueB) return 0;
|
|
1399
|
+
if (valueA == null) return order === "asc" ? -1 : 1;
|
|
1400
|
+
if (valueB == null) return order === "asc" ? 1 : -1;
|
|
1401
|
+
if (typeof valueA === "string" && typeof valueB === "string") {
|
|
1402
|
+
const comparison = valueA.localeCompare(valueB);
|
|
1403
|
+
return order === "asc" ? comparison : -comparison;
|
|
1404
|
+
}
|
|
1405
|
+
const numA = typeof valueA === "number" ? valueA : 0;
|
|
1406
|
+
const numB = typeof valueB === "number" ? valueB : 0;
|
|
1407
|
+
if (numA < numB) return order === "asc" ? -1 : 1;
|
|
1408
|
+
if (numA > numB) return order === "asc" ? 1 : -1;
|
|
1409
|
+
return 0;
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
function sum(arr) {
|
|
1413
|
+
return arr.reduce((acc, val) => acc + val, 0);
|
|
1414
|
+
}
|
|
1415
|
+
function average(arr) {
|
|
1416
|
+
if (arr.length === 0) return 0;
|
|
1417
|
+
return sum(arr) / arr.length;
|
|
1418
|
+
}
|
|
1419
|
+
function maxBy(arr, key) {
|
|
1420
|
+
if (arr.length === 0) return void 0;
|
|
1421
|
+
return arr.reduce((max, item) => {
|
|
1422
|
+
const value = typeof key === "function" ? key(item) : item[key];
|
|
1423
|
+
const maxValue = typeof key === "function" ? key(max) : max[key];
|
|
1424
|
+
return value > maxValue ? item : max;
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
function minBy(arr, key) {
|
|
1428
|
+
if (arr.length === 0) return void 0;
|
|
1429
|
+
return arr.reduce((min, item) => {
|
|
1430
|
+
const value = typeof key === "function" ? key(item) : item[key];
|
|
1431
|
+
const minValue = typeof key === "function" ? key(min) : min[key];
|
|
1432
|
+
return value < minValue ? item : min;
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
function moveItem(arr, fromIndex, toIndex) {
|
|
1436
|
+
if (fromIndex < 0 || fromIndex >= arr.length || toIndex < 0 || toIndex >= arr.length || fromIndex === toIndex) {
|
|
1437
|
+
return [...arr];
|
|
1438
|
+
}
|
|
1439
|
+
const result = [...arr];
|
|
1440
|
+
const [removed] = result.splice(fromIndex, 1);
|
|
1441
|
+
result.splice(toIndex, 0, removed);
|
|
1442
|
+
return result;
|
|
1443
|
+
}
|
|
1444
|
+
function swapItems(arr, index1, index2) {
|
|
1445
|
+
if (index1 < 0 || index1 >= arr.length || index2 < 0 || index2 >= arr.length || index1 === index2) {
|
|
1446
|
+
return [...arr];
|
|
1447
|
+
}
|
|
1448
|
+
const result = [...arr];
|
|
1449
|
+
[result[index1], result[index2]] = [result[index2], result[index1]];
|
|
1450
|
+
return result;
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
// src/string/index.ts
|
|
1454
|
+
function isEmpty(str) {
|
|
1455
|
+
if (str === null || str === void 0) return true;
|
|
1456
|
+
if (typeof str !== "string") return false;
|
|
1457
|
+
return str.trim().length === 0;
|
|
1458
|
+
}
|
|
1459
|
+
function isNotEmpty(str) {
|
|
1460
|
+
return !isEmpty(str);
|
|
1461
|
+
}
|
|
1462
|
+
function capitalize(str) {
|
|
1463
|
+
if (!str) return str;
|
|
1464
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1465
|
+
}
|
|
1466
|
+
function uncapitalize(str) {
|
|
1467
|
+
if (!str) return str;
|
|
1468
|
+
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
1469
|
+
}
|
|
1470
|
+
function camelCase(str) {
|
|
1471
|
+
return str.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : "").replace(/^[A-Z]/, (char) => char.toLowerCase());
|
|
1472
|
+
}
|
|
1473
|
+
function pascalCase(str) {
|
|
1474
|
+
const camel = camelCase(str);
|
|
1475
|
+
return capitalize(camel);
|
|
1476
|
+
}
|
|
1477
|
+
function kebabCase(str) {
|
|
1478
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
1479
|
+
}
|
|
1480
|
+
function snakeCase(str) {
|
|
1481
|
+
return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").toLowerCase();
|
|
1482
|
+
}
|
|
1483
|
+
function truncate(str, maxLength, suffix = "...") {
|
|
1484
|
+
if (str.length <= maxLength) return str;
|
|
1485
|
+
return str.slice(0, maxLength - suffix.length) + suffix;
|
|
1486
|
+
}
|
|
1487
|
+
function generateUUID() {
|
|
1488
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (char) => {
|
|
1489
|
+
const random = Math.random() * 16 | 0;
|
|
1490
|
+
const value = char === "x" ? random : random & 3 | 8;
|
|
1491
|
+
return value.toString(16);
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
function escapeHtml(str) {
|
|
1495
|
+
const htmlEscapes = {
|
|
1496
|
+
"&": "&",
|
|
1497
|
+
"<": "<",
|
|
1498
|
+
">": ">",
|
|
1499
|
+
'"': """,
|
|
1500
|
+
"'": "'"
|
|
1501
|
+
};
|
|
1502
|
+
return str.replace(/[&<>"']/g, (char) => htmlEscapes[char]);
|
|
1503
|
+
}
|
|
1504
|
+
function unescapeHtml(str) {
|
|
1505
|
+
const htmlUnescapes = {
|
|
1506
|
+
"&": "&",
|
|
1507
|
+
"<": "<",
|
|
1508
|
+
">": ">",
|
|
1509
|
+
""": '"',
|
|
1510
|
+
"'": "'"
|
|
1511
|
+
};
|
|
1512
|
+
return str.replace(/&(?:amp|lt|gt|quot|#39);/g, (entity) => htmlUnescapes[entity]);
|
|
1513
|
+
}
|
|
1514
|
+
function parseQueryString(url) {
|
|
1515
|
+
const queryString = url.includes("?") ? url.split("?")[1] : url;
|
|
1516
|
+
const params = new URLSearchParams(queryString);
|
|
1517
|
+
const result = {};
|
|
1518
|
+
params.forEach((value, key) => {
|
|
1519
|
+
result[key] = value;
|
|
1520
|
+
});
|
|
1521
|
+
return result;
|
|
1522
|
+
}
|
|
1523
|
+
function stringifyQueryString(params) {
|
|
1524
|
+
const searchParams = new URLSearchParams();
|
|
1525
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
1526
|
+
if (value !== void 0 && value !== null) {
|
|
1527
|
+
searchParams.append(key, String(value));
|
|
1528
|
+
}
|
|
1529
|
+
});
|
|
1530
|
+
const queryString = searchParams.toString();
|
|
1531
|
+
return queryString ? `?${queryString}` : "";
|
|
1532
|
+
}
|
|
1533
|
+
function buildUrl(baseUrl, params) {
|
|
1534
|
+
const queryString = stringifyQueryString(params);
|
|
1535
|
+
baseUrl.includes("?") ? "&" : queryString.replace("?", "?");
|
|
1536
|
+
return baseUrl + (baseUrl.includes("?") ? queryString.replace("?", "&") : queryString);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
// src/function/index.ts
|
|
1540
|
+
function debounce(func, options = {}) {
|
|
1541
|
+
const {
|
|
1542
|
+
wait = 0,
|
|
1543
|
+
leading = false,
|
|
1544
|
+
trailing = true
|
|
1545
|
+
} = options;
|
|
1546
|
+
let timer = null;
|
|
1547
|
+
let lastArgs = null;
|
|
1548
|
+
let lastThis = null;
|
|
1549
|
+
let result;
|
|
1550
|
+
function invokeFunc() {
|
|
1551
|
+
const args = lastArgs;
|
|
1552
|
+
const thisArg = lastThis;
|
|
1553
|
+
lastArgs = null;
|
|
1554
|
+
lastThis = null;
|
|
1555
|
+
result = func.apply(thisArg, args);
|
|
1556
|
+
return result;
|
|
1557
|
+
}
|
|
1558
|
+
function debounced(...args) {
|
|
1559
|
+
const shouldCallLeading = leading && timer === null;
|
|
1560
|
+
lastArgs = args;
|
|
1561
|
+
lastThis = this;
|
|
1562
|
+
if (timer !== null) {
|
|
1563
|
+
clearTimeout(timer);
|
|
1564
|
+
}
|
|
1565
|
+
if (shouldCallLeading) {
|
|
1566
|
+
invokeFunc();
|
|
1567
|
+
}
|
|
1568
|
+
timer = setTimeout(() => {
|
|
1569
|
+
timer = null;
|
|
1570
|
+
if (trailing && lastArgs) {
|
|
1571
|
+
invokeFunc();
|
|
1572
|
+
return;
|
|
1573
|
+
}
|
|
1574
|
+
lastArgs = null;
|
|
1575
|
+
lastThis = null;
|
|
1576
|
+
}, wait);
|
|
1577
|
+
return result;
|
|
1578
|
+
}
|
|
1579
|
+
debounced.cancel = function() {
|
|
1580
|
+
if (timer !== null) {
|
|
1581
|
+
clearTimeout(timer);
|
|
1582
|
+
}
|
|
1583
|
+
lastArgs = null;
|
|
1584
|
+
lastThis = null;
|
|
1585
|
+
timer = null;
|
|
1586
|
+
};
|
|
1587
|
+
debounced.flush = function() {
|
|
1588
|
+
if (timer === null) {
|
|
1589
|
+
return result;
|
|
1590
|
+
}
|
|
1591
|
+
clearTimeout(timer);
|
|
1592
|
+
timer = null;
|
|
1593
|
+
if (trailing && lastArgs) {
|
|
1594
|
+
return invokeFunc();
|
|
1595
|
+
}
|
|
1596
|
+
lastArgs = null;
|
|
1597
|
+
lastThis = null;
|
|
1598
|
+
return result;
|
|
1599
|
+
};
|
|
1600
|
+
debounced.pending = function() {
|
|
1601
|
+
return timer !== null;
|
|
1602
|
+
};
|
|
1603
|
+
return debounced;
|
|
1604
|
+
}
|
|
1605
|
+
function throttle(func, options = {}) {
|
|
1606
|
+
const {
|
|
1607
|
+
wait = 0,
|
|
1608
|
+
leading = true,
|
|
1609
|
+
trailing = true
|
|
1610
|
+
} = options;
|
|
1611
|
+
let timer = null;
|
|
1612
|
+
let lastArgs = null;
|
|
1613
|
+
let lastThis = null;
|
|
1614
|
+
let lastInvokeTime = null;
|
|
1615
|
+
let result;
|
|
1616
|
+
function invokeFunc(time) {
|
|
1617
|
+
const args = lastArgs;
|
|
1618
|
+
const thisArg = lastThis;
|
|
1619
|
+
lastArgs = null;
|
|
1620
|
+
lastThis = null;
|
|
1621
|
+
lastInvokeTime = time;
|
|
1622
|
+
result = func.apply(thisArg, args);
|
|
1623
|
+
return result;
|
|
1624
|
+
}
|
|
1625
|
+
function remainingWait(time) {
|
|
1626
|
+
const timeSinceLastInvoke = time - (lastInvokeTime != null ? lastInvokeTime : 0);
|
|
1627
|
+
return wait - timeSinceLastInvoke;
|
|
1628
|
+
}
|
|
1629
|
+
function startTimer(delay) {
|
|
1630
|
+
timer = setTimeout(() => {
|
|
1631
|
+
timer = null;
|
|
1632
|
+
if (trailing && lastArgs) {
|
|
1633
|
+
invokeFunc(Date.now());
|
|
1634
|
+
return;
|
|
1635
|
+
}
|
|
1636
|
+
lastArgs = null;
|
|
1637
|
+
lastThis = null;
|
|
1638
|
+
}, delay);
|
|
1639
|
+
}
|
|
1640
|
+
function throttled(...args) {
|
|
1641
|
+
const time = Date.now();
|
|
1642
|
+
lastArgs = args;
|
|
1643
|
+
lastThis = this;
|
|
1644
|
+
if (lastInvokeTime === null) {
|
|
1645
|
+
if (leading) {
|
|
1646
|
+
return invokeFunc(time);
|
|
1647
|
+
}
|
|
1648
|
+
lastInvokeTime = time;
|
|
1649
|
+
}
|
|
1650
|
+
const waitRemaining = remainingWait(time);
|
|
1651
|
+
if (waitRemaining <= 0) {
|
|
1652
|
+
if (timer !== null) {
|
|
1653
|
+
clearTimeout(timer);
|
|
1654
|
+
timer = null;
|
|
1655
|
+
}
|
|
1656
|
+
return invokeFunc(time);
|
|
1657
|
+
}
|
|
1658
|
+
if (timer === null && trailing) {
|
|
1659
|
+
startTimer(waitRemaining);
|
|
1660
|
+
}
|
|
1661
|
+
return result;
|
|
1662
|
+
}
|
|
1663
|
+
throttled.cancel = function() {
|
|
1664
|
+
if (timer !== null) {
|
|
1665
|
+
clearTimeout(timer);
|
|
1666
|
+
}
|
|
1667
|
+
lastArgs = null;
|
|
1668
|
+
lastThis = null;
|
|
1669
|
+
lastInvokeTime = null;
|
|
1670
|
+
timer = null;
|
|
1671
|
+
};
|
|
1672
|
+
throttled.flush = function() {
|
|
1673
|
+
if (timer === null) {
|
|
1674
|
+
return result;
|
|
1675
|
+
}
|
|
1676
|
+
clearTimeout(timer);
|
|
1677
|
+
timer = null;
|
|
1678
|
+
if (lastArgs) {
|
|
1679
|
+
return invokeFunc(Date.now());
|
|
1680
|
+
}
|
|
1681
|
+
return result;
|
|
1682
|
+
};
|
|
1683
|
+
throttled.pending = function() {
|
|
1684
|
+
return timer !== null;
|
|
1685
|
+
};
|
|
1686
|
+
return throttled;
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
// src/get/index.ts
|
|
1690
|
+
function get(obj, path, defaultValue) {
|
|
1691
|
+
if (obj == null) return defaultValue;
|
|
1692
|
+
const keys = Array.isArray(path) ? path : path.split(".");
|
|
1693
|
+
let result = obj;
|
|
1694
|
+
for (const key of keys) {
|
|
1695
|
+
if (result == null) {
|
|
1696
|
+
return defaultValue;
|
|
1697
|
+
}
|
|
1698
|
+
result = result[key];
|
|
1699
|
+
}
|
|
1700
|
+
return result !== void 0 ? result : defaultValue;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
exports.REGEXP_AMOUNT = REGEXP_AMOUNT;
|
|
1704
|
+
exports.REGEXP_BANK_CARD = REGEXP_BANK_CARD;
|
|
1705
|
+
exports.REGEXP_CAR_PLATE = REGEXP_CAR_PLATE;
|
|
1706
|
+
exports.REGEXP_CHINESE = REGEXP_CHINESE;
|
|
1707
|
+
exports.REGEXP_DECIMAL = REGEXP_DECIMAL;
|
|
1708
|
+
exports.REGEXP_EMAIL = REGEXP_EMAIL;
|
|
1709
|
+
exports.REGEXP_FIXED_PHONE = REGEXP_FIXED_PHONE;
|
|
1710
|
+
exports.REGEXP_ID_CARD = REGEXP_ID_CARD;
|
|
1711
|
+
exports.REGEXP_INTEGER = REGEXP_INTEGER;
|
|
1712
|
+
exports.REGEXP_IPV4 = REGEXP_IPV4;
|
|
1713
|
+
exports.REGEXP_IPV6 = REGEXP_IPV6;
|
|
1714
|
+
exports.REGEXP_PASSPORT = REGEXP_PASSPORT;
|
|
1715
|
+
exports.REGEXP_PASSWORD = REGEXP_PASSWORD;
|
|
1716
|
+
exports.REGEXP_PHONE = REGEXP_PHONE;
|
|
1717
|
+
exports.REGEXP_PORT = REGEXP_PORT;
|
|
1718
|
+
exports.REGEXP_POSITIVE_INTEGER = REGEXP_POSITIVE_INTEGER;
|
|
1719
|
+
exports.REGEXP_POSTAL_CODE = REGEXP_POSTAL_CODE;
|
|
1720
|
+
exports.REGEXP_QQ = REGEXP_QQ;
|
|
1721
|
+
exports.REGEXP_STRONG_PASSWORD = REGEXP_STRONG_PASSWORD;
|
|
1722
|
+
exports.REGEXP_URL = REGEXP_URL;
|
|
1723
|
+
exports.REGEXP_USERNAME = REGEXP_USERNAME;
|
|
1724
|
+
exports.addDays = addDays;
|
|
1725
|
+
exports.average = average;
|
|
1726
|
+
exports.base64ToBlob = base64ToBlob;
|
|
1727
|
+
exports.buildUrl = buildUrl;
|
|
1728
|
+
exports.cache = cache;
|
|
1729
|
+
exports.camelCase = camelCase;
|
|
1730
|
+
exports.capitalize = capitalize;
|
|
1731
|
+
exports.chunk = chunk;
|
|
1732
|
+
exports.clamp = clamp;
|
|
1733
|
+
exports.copyText = copyText;
|
|
1734
|
+
exports.createCache = createCache;
|
|
1735
|
+
exports.createCrypto = createCrypto;
|
|
1736
|
+
exports.createStorage = createStorage;
|
|
1737
|
+
exports.debounce = debounce;
|
|
1738
|
+
exports.decrypt = decrypt;
|
|
1739
|
+
exports.decryptAes = decryptAes;
|
|
1740
|
+
exports.decryptRsa = decryptRsa;
|
|
1741
|
+
exports.decryptSm2 = decryptSm2;
|
|
1742
|
+
exports.decryptSm4 = decryptSm4;
|
|
1743
|
+
exports.deepClone = deepClone;
|
|
1744
|
+
exports.deepMerge = deepMerge;
|
|
1745
|
+
exports.diffDays = diffDays;
|
|
1746
|
+
exports.diffHours = diffHours;
|
|
1747
|
+
exports.difference = difference;
|
|
1748
|
+
exports.downloadBlob = downloadBlob;
|
|
1749
|
+
exports.downloadJSON = downloadJSON;
|
|
1750
|
+
exports.downloadStream = downloadStream;
|
|
1751
|
+
exports.downloadText = downloadText;
|
|
1752
|
+
exports.encrypt = encrypt;
|
|
1753
|
+
exports.encryptAes = encryptAes;
|
|
1754
|
+
exports.encryptRsa = encryptRsa;
|
|
1755
|
+
exports.encryptSm2 = encryptSm2;
|
|
1756
|
+
exports.encryptSm4 = encryptSm4;
|
|
1757
|
+
exports.endOfDay = endOfDay;
|
|
1758
|
+
exports.escapeHtml = escapeHtml;
|
|
1759
|
+
exports.fileToBase64 = fileToBase64;
|
|
1760
|
+
exports.filterTree = filterTree;
|
|
1761
|
+
exports.findTreeNode = findTreeNode;
|
|
1762
|
+
exports.flatten = flatten;
|
|
1763
|
+
exports.flattenArray = flattenArray;
|
|
1764
|
+
exports.formatDate = formatDate;
|
|
1765
|
+
exports.formatFileSize = formatFileSize;
|
|
1766
|
+
exports.formatMoney = formatMoney;
|
|
1767
|
+
exports.formatPercent = formatPercent;
|
|
1768
|
+
exports.formatThousands = formatThousands;
|
|
1769
|
+
exports.fromBase64 = fromBase64;
|
|
1770
|
+
exports.fromNow = fromNow;
|
|
1771
|
+
exports.generateUUID = generateUUID;
|
|
1772
|
+
exports.get = get;
|
|
1773
|
+
exports.getFileExtension = getFileExtension;
|
|
1774
|
+
exports.getTreeLeaves = getTreeLeaves;
|
|
1775
|
+
exports.getTreePath = getTreePath;
|
|
1776
|
+
exports.groupBy = groupBy;
|
|
1777
|
+
exports.intersection = intersection;
|
|
1778
|
+
exports.isAmount = isAmount;
|
|
1779
|
+
exports.isBankCard = isBankCard;
|
|
1780
|
+
exports.isCarPlate = isCarPlate;
|
|
1781
|
+
exports.isChinese = isChinese;
|
|
1782
|
+
exports.isDecimal = isDecimal;
|
|
1783
|
+
exports.isEmail = isEmail;
|
|
1784
|
+
exports.isEmpty = isEmpty;
|
|
1785
|
+
exports.isFixedPhone = isFixedPhone;
|
|
1786
|
+
exports.isIdCard = isIdCard;
|
|
1787
|
+
exports.isInteger = isInteger;
|
|
1788
|
+
exports.isIpv4 = isIpv4;
|
|
1789
|
+
exports.isIpv6 = isIpv6;
|
|
1790
|
+
exports.isNotEmpty = isNotEmpty;
|
|
1791
|
+
exports.isPassport = isPassport;
|
|
1792
|
+
exports.isPassword = isPassword;
|
|
1793
|
+
exports.isPhone = isPhone;
|
|
1794
|
+
exports.isPort = isPort;
|
|
1795
|
+
exports.isPositiveInteger = isPositiveInteger;
|
|
1796
|
+
exports.isPostalCode = isPostalCode;
|
|
1797
|
+
exports.isQq = isQq;
|
|
1798
|
+
exports.isStrongPassword = isStrongPassword;
|
|
1799
|
+
exports.isUrl = isUrl;
|
|
1800
|
+
exports.isUsername = isUsername;
|
|
1801
|
+
exports.isValidDate = isValidDate;
|
|
1802
|
+
exports.kebabCase = kebabCase;
|
|
1803
|
+
exports.listToTree = listToTree;
|
|
1804
|
+
exports.localStore = localStore;
|
|
1805
|
+
exports.mask = mask;
|
|
1806
|
+
exports.maskAccount = maskAccount;
|
|
1807
|
+
exports.maskAddress = maskAddress;
|
|
1808
|
+
exports.maskBankCard = maskBankCard;
|
|
1809
|
+
exports.maskCarPlate = maskCarPlate;
|
|
1810
|
+
exports.maskEmail = maskEmail;
|
|
1811
|
+
exports.maskFixedPhone = maskFixedPhone;
|
|
1812
|
+
exports.maskIdCard = maskIdCard;
|
|
1813
|
+
exports.maskIp = maskIp;
|
|
1814
|
+
exports.maskName = maskName;
|
|
1815
|
+
exports.maskPassport = maskPassport;
|
|
1816
|
+
exports.maskPhone = maskPhone;
|
|
1817
|
+
exports.maskSecret = maskSecret;
|
|
1818
|
+
exports.maxBy = maxBy;
|
|
1819
|
+
exports.md5 = md5;
|
|
1820
|
+
exports.minBy = minBy;
|
|
1821
|
+
exports.moveItem = moveItem;
|
|
1822
|
+
exports.omit = omit;
|
|
1823
|
+
exports.parseQueryString = parseQueryString;
|
|
1824
|
+
exports.pascalCase = pascalCase;
|
|
1825
|
+
exports.pick = pick;
|
|
1826
|
+
exports.regexp = regexp;
|
|
1827
|
+
exports.removeEmptyValues = removeEmptyValues;
|
|
1828
|
+
exports.sessionStore = sessionStore;
|
|
1829
|
+
exports.sha256 = sha256;
|
|
1830
|
+
exports.shuffle = shuffle;
|
|
1831
|
+
exports.snakeCase = snakeCase;
|
|
1832
|
+
exports.sortBy = sortBy;
|
|
1833
|
+
exports.startOfDay = startOfDay;
|
|
1834
|
+
exports.stringifyQueryString = stringifyQueryString;
|
|
1835
|
+
exports.sum = sum;
|
|
1836
|
+
exports.swapItems = swapItems;
|
|
1837
|
+
exports.testRegexp = testRegexp;
|
|
1838
|
+
exports.throttle = throttle;
|
|
1839
|
+
exports.toBase64 = toBase64;
|
|
1840
|
+
exports.toDate = toDate;
|
|
1841
|
+
exports.toFixedSafe = toFixedSafe;
|
|
1842
|
+
exports.treeToList = treeToList;
|
|
1843
|
+
exports.truncate = truncate;
|
|
1844
|
+
exports.uncapitalize = uncapitalize;
|
|
1845
|
+
exports.unescapeHtml = unescapeHtml;
|
|
1846
|
+
exports.unflatten = unflatten;
|
|
1847
|
+
exports.unique = unique;
|
|
1848
|
+
exports.uniqueBy = uniqueBy;
|
|
1849
|
+
//# sourceMappingURL=index.cjs.map
|
|
1850
|
+
//# sourceMappingURL=index.cjs.map
|