@jhqn/utils-core 0.0.3-beta.6 → 0.0.3-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +85 -39
- package/dist/index.d.cts +146 -106
- package/dist/index.d.mts +146 -106
- package/dist/index.d.ts +146 -106
- package/dist/index.mjs +79 -36
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
const detectBrowser = require('detect-browser');
|
|
4
4
|
const dayjs = require('dayjs');
|
|
5
|
-
const
|
|
6
|
-
const duration = require('dayjs/plugin/duration');
|
|
7
|
-
const relativeTime = require('dayjs/plugin/relativeTime');
|
|
5
|
+
const zhCN = require('dayjs/locale/zh-cn');
|
|
8
6
|
const customParseFormat = require('dayjs/plugin/customParseFormat');
|
|
7
|
+
const duration = require('dayjs/plugin/duration');
|
|
8
|
+
const localeData = require('dayjs/plugin/localeData');
|
|
9
9
|
const objectSupport = require('dayjs/plugin/objectSupport');
|
|
10
|
-
const
|
|
10
|
+
const relativeTime = require('dayjs/plugin/relativeTime');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
13
13
|
|
|
14
14
|
const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
|
|
15
|
-
const
|
|
16
|
-
const duration__default = /*#__PURE__*/_interopDefaultCompat(duration);
|
|
17
|
-
const relativeTime__default = /*#__PURE__*/_interopDefaultCompat(relativeTime);
|
|
15
|
+
const zhCN__default = /*#__PURE__*/_interopDefaultCompat(zhCN);
|
|
18
16
|
const customParseFormat__default = /*#__PURE__*/_interopDefaultCompat(customParseFormat);
|
|
17
|
+
const duration__default = /*#__PURE__*/_interopDefaultCompat(duration);
|
|
18
|
+
const localeData__default = /*#__PURE__*/_interopDefaultCompat(localeData);
|
|
19
19
|
const objectSupport__default = /*#__PURE__*/_interopDefaultCompat(objectSupport);
|
|
20
|
-
const
|
|
20
|
+
const relativeTime__default = /*#__PURE__*/_interopDefaultCompat(relativeTime);
|
|
21
21
|
|
|
22
22
|
const snake2Kebab = (str) => str.replace(/_([a-z])/g, (_, letter) => `-${letter.toLowerCase()}`);
|
|
23
23
|
const snake2Pascal = (str) => str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()).replace(/^[a-z]/, (letter) => letter.toUpperCase());
|
|
@@ -120,6 +120,7 @@ const isJSONStr = (str) => {
|
|
|
120
120
|
JSON.parse(str);
|
|
121
121
|
return true;
|
|
122
122
|
} catch (e) {
|
|
123
|
+
jError("isJSONStr", e);
|
|
123
124
|
return false;
|
|
124
125
|
}
|
|
125
126
|
}
|
|
@@ -130,6 +131,7 @@ const isArrStr = (str) => {
|
|
|
130
131
|
try {
|
|
131
132
|
return Array.isArray(JSON.parse(str));
|
|
132
133
|
} catch (e) {
|
|
134
|
+
jError("isArrStr", e);
|
|
133
135
|
return false;
|
|
134
136
|
}
|
|
135
137
|
}
|
|
@@ -140,13 +142,14 @@ const isEmpty = (val) => {
|
|
|
140
142
|
return !isDef(val) || val === "" || isArray(val) && val.length === 0 || isObject(val) && Object.keys(val).length === 0 || isMap(val) && val.size === 0 || isSet(val) && val.size === 0;
|
|
141
143
|
};
|
|
142
144
|
|
|
143
|
-
const isValidResCode = (res, code = 200) => res.code === code;
|
|
144
|
-
const isValidRes = (res, code) => isValidResCode(res, code) && isDef(res.data);
|
|
145
|
-
const isValidArrRes = (res, code) => isValidResCode(res, code) && Array.isArray(res.data);
|
|
146
|
-
const isValidPageRes = (res, code) => isValidResCode(res, code) && isDef(res.data) && Array.isArray(res.data.list || res.data.records);
|
|
147
|
-
|
|
148
145
|
const cnPhoneRE = /^1[3-9]\d{9}$/;
|
|
149
146
|
const cnTelRE = /^0\d{9,11}$/;
|
|
147
|
+
const cnUSCIRE = /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/;
|
|
148
|
+
const isUSCI = (val) => {
|
|
149
|
+
if (!isDef(val))
|
|
150
|
+
return false;
|
|
151
|
+
return cnUSCIRE.test(val);
|
|
152
|
+
};
|
|
150
153
|
const isPhone = (val) => {
|
|
151
154
|
if (!isDef(val))
|
|
152
155
|
return false;
|
|
@@ -203,6 +206,11 @@ const isValidFileType = (file, type) => {
|
|
|
203
206
|
return validate(type);
|
|
204
207
|
};
|
|
205
208
|
|
|
209
|
+
const isValidResCode = (res, code = 200) => res.code === code;
|
|
210
|
+
const isValidRes = (res, code) => isValidResCode(res, code) && isDef(res.data);
|
|
211
|
+
const isValidArrRes = (res, code) => isValidResCode(res, code) && Array.isArray(res.data);
|
|
212
|
+
const isValidPageRes = (res, code) => isValidResCode(res, code) && isDef(res.data) && Array.isArray(res.data.list || res.data.records);
|
|
213
|
+
|
|
206
214
|
const hideMiddle = (str) => {
|
|
207
215
|
if (!isDef(str))
|
|
208
216
|
return "";
|
|
@@ -313,14 +321,34 @@ const hideBankCard = (bankCard) => {
|
|
|
313
321
|
return "";
|
|
314
322
|
};
|
|
315
323
|
|
|
324
|
+
let __BASE_ATTACH_URL__;
|
|
325
|
+
function setBaseAttachUrl(baseUrl) {
|
|
326
|
+
__BASE_ATTACH_URL__ = baseUrl;
|
|
327
|
+
}
|
|
328
|
+
function getBaseAttachUrl() {
|
|
329
|
+
return __BASE_ATTACH_URL__;
|
|
330
|
+
}
|
|
331
|
+
|
|
316
332
|
const parseToJSON = (str, reviver2) => isJSONStr(str) ? JSON.parse(str, reviver2) : null;
|
|
317
333
|
const replacer = (_, value) => {
|
|
318
|
-
if (value
|
|
334
|
+
if (isMap(value)) {
|
|
319
335
|
return {
|
|
320
336
|
dataType: "Map",
|
|
321
337
|
value: [...value]
|
|
322
338
|
};
|
|
323
339
|
}
|
|
340
|
+
if (isSet(value)) {
|
|
341
|
+
return {
|
|
342
|
+
dataType: "Set",
|
|
343
|
+
value: [...value]
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
if (isDate(value)) {
|
|
347
|
+
return {
|
|
348
|
+
dataType: "Date",
|
|
349
|
+
value: value.toISOString()
|
|
350
|
+
};
|
|
351
|
+
}
|
|
324
352
|
return value;
|
|
325
353
|
};
|
|
326
354
|
const reviver = (_, value) => {
|
|
@@ -328,11 +356,33 @@ const reviver = (_, value) => {
|
|
|
328
356
|
if (value.dataType === "Map") {
|
|
329
357
|
return new Map(value.value);
|
|
330
358
|
}
|
|
359
|
+
if (value.dataType === "Set") {
|
|
360
|
+
return new Set(value.value);
|
|
361
|
+
}
|
|
362
|
+
if (value.dataType === "Date") {
|
|
363
|
+
return new Date(value.value);
|
|
364
|
+
}
|
|
331
365
|
}
|
|
332
366
|
return value;
|
|
333
367
|
};
|
|
334
368
|
const filterObj = (obj, keys, reverse = false) => Object.fromEntries(Object.entries(obj).filter(([key]) => reverse ? !keys.includes(key) : keys.includes(key)));
|
|
335
369
|
|
|
370
|
+
const toThousands = (num) => {
|
|
371
|
+
const arr = num.toString().split(".");
|
|
372
|
+
const integer = arr[0]?.replace(/(\d)(?=(?:\d{3})+$)/g, "$1,");
|
|
373
|
+
if (arr.length > 1)
|
|
374
|
+
return `${integer}.${arr[1]}`;
|
|
375
|
+
return integer;
|
|
376
|
+
};
|
|
377
|
+
const currencyFmt = (currency, maximumFractionDigits = 2) => {
|
|
378
|
+
if (!isDef(currency))
|
|
379
|
+
return "";
|
|
380
|
+
const num = Number(currency);
|
|
381
|
+
if (Number.isNaN(num))
|
|
382
|
+
return "";
|
|
383
|
+
return new Intl.NumberFormat("zh-CN", { style: "currency", currency: "CNY", maximumFractionDigits }).format(num);
|
|
384
|
+
};
|
|
385
|
+
|
|
336
386
|
dayjs__default.extend(localeData__default).locale("zh-cn", zhCN__default);
|
|
337
387
|
dayjs__default.extend(duration__default);
|
|
338
388
|
dayjs__default.extend(relativeTime__default);
|
|
@@ -366,34 +416,10 @@ const dateDuration = (start, end) => {
|
|
|
366
416
|
return dd.format(format);
|
|
367
417
|
};
|
|
368
418
|
|
|
369
|
-
let __BASE_ATTACH_URL__;
|
|
370
|
-
function setBaseAttachUrl(baseUrl) {
|
|
371
|
-
__BASE_ATTACH_URL__ = baseUrl;
|
|
372
|
-
}
|
|
373
|
-
function getBaseAttachUrl() {
|
|
374
|
-
return __BASE_ATTACH_URL__;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
const toThousands = (num) => {
|
|
378
|
-
const arr = num.toString().split(".");
|
|
379
|
-
const integer = arr[0]?.replace(/(\d)(?=(?:\d{3})+$)/g, "$1,");
|
|
380
|
-
if (arr.length > 1)
|
|
381
|
-
return `${integer}.${arr[1]}`;
|
|
382
|
-
return integer;
|
|
383
|
-
};
|
|
384
|
-
const currencyFmt = (currency, maximumFractionDigits = 2) => {
|
|
385
|
-
if (!isDef(currency))
|
|
386
|
-
return "";
|
|
387
|
-
const num = Number(currency);
|
|
388
|
-
if (Number.isNaN(num))
|
|
389
|
-
return "";
|
|
390
|
-
return new Intl.NumberFormat("zh-CN", { style: "currency", currency: "CNY", maximumFractionDigits }).format(num);
|
|
391
|
-
};
|
|
392
|
-
|
|
393
419
|
const resUrl = (url) => {
|
|
394
420
|
if (!isDef(url))
|
|
395
421
|
return void 0;
|
|
396
|
-
if (/^https?:\/\//.test(url) ||
|
|
422
|
+
if (/^https?:\/\//.test(url) || url.startsWith("blob:") || url.startsWith("data:")) {
|
|
397
423
|
return url;
|
|
398
424
|
}
|
|
399
425
|
const baseUrl = getBaseAttachUrl();
|
|
@@ -438,6 +464,23 @@ const attachFmt = (data) => {
|
|
|
438
464
|
return attachList.map(recoverFile);
|
|
439
465
|
};
|
|
440
466
|
|
|
467
|
+
const isNumberArray = (arr) => arr.every((item) => typeof item === "number");
|
|
468
|
+
const isStringArray = (arr) => arr.every((item) => typeof item === "string");
|
|
469
|
+
const naturalSort = (arr) => {
|
|
470
|
+
if (isNumberArray(arr))
|
|
471
|
+
return [...arr].sort((a, b) => a - b);
|
|
472
|
+
if (isStringArray(arr)) {
|
|
473
|
+
return [...arr].sort((a, b) => a.localeCompare(b, "zh-CN")).sort((a, b) => a.length - b.length);
|
|
474
|
+
}
|
|
475
|
+
const newArr = [...arr].sort();
|
|
476
|
+
const validArr = newArr.filter((a) => isDef(a));
|
|
477
|
+
const invalidArr = newArr.filter((a) => !isDef(a));
|
|
478
|
+
return naturalSort(validArr).concat(invalidArr);
|
|
479
|
+
};
|
|
480
|
+
const naturalSortBy = (arr, key) => {
|
|
481
|
+
return [...arr].sort((a, b) => naturalSort([a[key], b[key]])[0] === a[key] ? -1 : 1);
|
|
482
|
+
};
|
|
483
|
+
|
|
441
484
|
const inBrowser = typeof window !== "undefined";
|
|
442
485
|
const waitTime = (time = 100) => {
|
|
443
486
|
return new Promise((resolve) => {
|
|
@@ -539,6 +582,7 @@ exports.isString = isString;
|
|
|
539
582
|
exports.isSymbol = isSymbol;
|
|
540
583
|
exports.isTel = isTel;
|
|
541
584
|
exports.isURL = isURL;
|
|
585
|
+
exports.isUSCI = isUSCI;
|
|
542
586
|
exports.isUndefined = isUndefined;
|
|
543
587
|
exports.isValidArrRes = isValidArrRes;
|
|
544
588
|
exports.isValidFileType = isValidFileType;
|
|
@@ -565,6 +609,8 @@ exports.kebab2Camel = kebab2Camel;
|
|
|
565
609
|
exports.kebab2Pascal = kebab2Pascal;
|
|
566
610
|
exports.kebab2Snake = kebab2Snake;
|
|
567
611
|
exports.kebab2Title = kebab2Title;
|
|
612
|
+
exports.naturalSort = naturalSort;
|
|
613
|
+
exports.naturalSortBy = naturalSortBy;
|
|
568
614
|
exports.nonASCII = nonASCII;
|
|
569
615
|
exports.parseToJSON = parseToJSON;
|
|
570
616
|
exports.pascal2Camel = pascal2Camel;
|
package/dist/index.d.cts
CHANGED
|
@@ -7,6 +7,59 @@ import { ConfigType } from 'dayjs';
|
|
|
7
7
|
export { Dayjs, default as dayjs } from 'dayjs';
|
|
8
8
|
export { detect } from 'detect-browser';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* 数字或字符串
|
|
12
|
+
*/
|
|
13
|
+
type Numeric = number | string;
|
|
14
|
+
/**
|
|
15
|
+
* 可 Null
|
|
16
|
+
*/
|
|
17
|
+
type Nullable<T> = T | null;
|
|
18
|
+
/**
|
|
19
|
+
* 可 Undefined
|
|
20
|
+
*/
|
|
21
|
+
type Undefinable<T> = T | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* 可 Null 或 Undefined
|
|
24
|
+
*/
|
|
25
|
+
type NullOrUndefinable<T> = Nullable<Undefinable<T>>;
|
|
26
|
+
/**
|
|
27
|
+
* alias for NullOrUndefinable
|
|
28
|
+
*/
|
|
29
|
+
type UnDef<T> = NullOrUndefinable<T>;
|
|
30
|
+
/**
|
|
31
|
+
* 请求结果
|
|
32
|
+
*/
|
|
33
|
+
type Res<T = any> = Service.Response<T>;
|
|
34
|
+
/**
|
|
35
|
+
* 分页请求结果数据
|
|
36
|
+
*/
|
|
37
|
+
type PageResData<T = any> = Service.PageResponseData<T>;
|
|
38
|
+
/**
|
|
39
|
+
* 分页请求结果
|
|
40
|
+
*/
|
|
41
|
+
type PageRes<T = any> = Service.PageResponse<T>;
|
|
42
|
+
/**
|
|
43
|
+
* 分页请求参数
|
|
44
|
+
*/
|
|
45
|
+
type PageReq<T extends Record<string, any> = NonNullable<unknown>> = Service.PageRequestParams<T>;
|
|
46
|
+
/**
|
|
47
|
+
* 可能是数组
|
|
48
|
+
*/
|
|
49
|
+
type MaybeArray<T = any> = T | Array<T>;
|
|
50
|
+
/**
|
|
51
|
+
* 枚举键值对
|
|
52
|
+
*/
|
|
53
|
+
type VK<T = string> = Record<string | number, T>;
|
|
54
|
+
/**
|
|
55
|
+
* 字典
|
|
56
|
+
*/
|
|
57
|
+
type Dict<T = string> = Record<string, T>;
|
|
58
|
+
/**
|
|
59
|
+
* 使某键可选
|
|
60
|
+
*/
|
|
61
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
62
|
+
|
|
10
63
|
/**
|
|
11
64
|
* snake2Kebab
|
|
12
65
|
* @param {string} str 字符串
|
|
@@ -217,43 +270,6 @@ declare const jLogDedupe: (...args: any[]) => void;
|
|
|
217
270
|
*/
|
|
218
271
|
declare const jLogOnce: (...args: any[]) => void;
|
|
219
272
|
|
|
220
|
-
/**
|
|
221
|
-
* 数字或字符串
|
|
222
|
-
*/
|
|
223
|
-
declare type Numeric = number | string;
|
|
224
|
-
/**
|
|
225
|
-
* 可 Null
|
|
226
|
-
*/
|
|
227
|
-
declare type Nullable<T> = T | null;
|
|
228
|
-
/**
|
|
229
|
-
* 可 Undefined
|
|
230
|
-
*/
|
|
231
|
-
declare type Undefinable<T> = T | undefined;
|
|
232
|
-
/**
|
|
233
|
-
* 可 Null 或 Undefined
|
|
234
|
-
*/
|
|
235
|
-
declare type NullOrUndefinable<T> = Nullable<Undefinable<T>>;
|
|
236
|
-
/**
|
|
237
|
-
* alias for NullOrUndefinable
|
|
238
|
-
*/
|
|
239
|
-
declare type UnDef<T> = NullOrUndefinable<T>;
|
|
240
|
-
/**
|
|
241
|
-
* 请求结果
|
|
242
|
-
*/
|
|
243
|
-
declare type Res<T = any> = Service.Response<T>;
|
|
244
|
-
/**
|
|
245
|
-
* 分页请求结果数据
|
|
246
|
-
*/
|
|
247
|
-
declare type PageResData<T = any> = Service.PageResponseData<T>;
|
|
248
|
-
/**
|
|
249
|
-
* 分页请求结果
|
|
250
|
-
*/
|
|
251
|
-
declare type PageRes<T = any> = Service.PageResponse<T>;
|
|
252
|
-
/**
|
|
253
|
-
* 可能是数组
|
|
254
|
-
*/
|
|
255
|
-
declare type MaybeArray<T = any> = T | Array<T>;
|
|
256
|
-
|
|
257
273
|
/**
|
|
258
274
|
* 隐藏中间部分
|
|
259
275
|
* @param {string} str 需要隐藏的字符串
|
|
@@ -392,6 +408,16 @@ declare const getCodeOfDate: () => number;
|
|
|
392
408
|
*/
|
|
393
409
|
declare const getCodeOfMonth: () => number;
|
|
394
410
|
|
|
411
|
+
/**
|
|
412
|
+
* 设置文件基本路径
|
|
413
|
+
* @param baseUrl
|
|
414
|
+
*/
|
|
415
|
+
declare function setBaseAttachUrl(baseUrl: string): void;
|
|
416
|
+
/**
|
|
417
|
+
* 获取文件基本路径
|
|
418
|
+
*/
|
|
419
|
+
declare function getBaseAttachUrl(): string;
|
|
420
|
+
|
|
395
421
|
/**
|
|
396
422
|
* Json字符串转对象
|
|
397
423
|
* @param str
|
|
@@ -420,13 +446,25 @@ declare const filterObj: (obj: Record<string, any>, keys: string[], reverse?: bo
|
|
|
420
446
|
[k: string]: any;
|
|
421
447
|
};
|
|
422
448
|
|
|
449
|
+
/**
|
|
450
|
+
* 千位分隔符
|
|
451
|
+
* @param num
|
|
452
|
+
*/
|
|
453
|
+
declare const toThousands: (num: number) => string | undefined;
|
|
454
|
+
/**
|
|
455
|
+
* 货币格式化
|
|
456
|
+
* @param {number | string | bigint} currency - 金额
|
|
457
|
+
* @param {number} [maximumFractionDigits] - 小数位数
|
|
458
|
+
*/
|
|
459
|
+
declare const currencyFmt: (currency: UnDef<Numeric | bigint>, maximumFractionDigits?: number) => string;
|
|
460
|
+
|
|
423
461
|
/**
|
|
424
462
|
* 格式化时间
|
|
425
463
|
* @param {import('dayjs').ConfigType} date 时间
|
|
426
464
|
* @param {string} format 格式
|
|
427
465
|
* @returns {string} 格式化后的时间
|
|
428
466
|
*/
|
|
429
|
-
declare const dateFmt: (date: ConfigType, format?: string |
|
|
467
|
+
declare const dateFmt: (date: ConfigType, format?: string | "date" | "datetime") => string;
|
|
430
468
|
/**
|
|
431
469
|
* 格式化时间间隔
|
|
432
470
|
* @param {import('dayjs').ConfigType} start 开始时间
|
|
@@ -434,28 +472,6 @@ declare const dateFmt: (date: ConfigType, format?: string | 'date' | 'datetime')
|
|
|
434
472
|
*/
|
|
435
473
|
declare const dateDuration: (start: ConfigType, end: ConfigType) => string;
|
|
436
474
|
|
|
437
|
-
/**
|
|
438
|
-
* 设置文件基本路径
|
|
439
|
-
* @param baseUrl
|
|
440
|
-
*/
|
|
441
|
-
declare function setBaseAttachUrl(baseUrl: string): void;
|
|
442
|
-
/**
|
|
443
|
-
* 获取文件基本路径
|
|
444
|
-
*/
|
|
445
|
-
declare function getBaseAttachUrl(): string;
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* 千位分隔符
|
|
449
|
-
* @param num
|
|
450
|
-
*/
|
|
451
|
-
declare const toThousands: (num: number) => string | undefined;
|
|
452
|
-
/**
|
|
453
|
-
* 货币格式化
|
|
454
|
-
* @param {number | string | bigint} currency - 金额
|
|
455
|
-
* @param {number} [maximumFractionDigits] - 小数位数
|
|
456
|
-
*/
|
|
457
|
-
declare const currencyFmt: (currency: UnDef<Numeric | bigint>, maximumFractionDigits?: number) => string;
|
|
458
|
-
|
|
459
475
|
type VantUploadFileStatus = '' | 'uploading' | 'done' | 'failed'
|
|
460
476
|
type AntdUploadFileStatus = 'removed' | 'uploading' | 'done' | 'error'
|
|
461
477
|
type ElementPlusUploadFileStatus = 'ready' | 'uploading' | 'success' | 'fail'
|
|
@@ -504,16 +520,16 @@ declare const recoverFile: (resource: Resource) => {
|
|
|
504
520
|
group: string;
|
|
505
521
|
id: string;
|
|
506
522
|
name: string;
|
|
507
|
-
size?: number
|
|
508
|
-
uid?: string
|
|
509
|
-
objectUrl?: string
|
|
510
|
-
isImage?: boolean
|
|
511
|
-
message?: string
|
|
512
|
-
deletable?: boolean
|
|
513
|
-
reupload?: boolean
|
|
514
|
-
fileName?: string
|
|
515
|
-
thumbUrl?: string
|
|
516
|
-
percentage?: number
|
|
523
|
+
size?: number;
|
|
524
|
+
uid?: string;
|
|
525
|
+
objectUrl?: string;
|
|
526
|
+
isImage?: boolean;
|
|
527
|
+
message?: string;
|
|
528
|
+
deletable?: boolean;
|
|
529
|
+
reupload?: boolean;
|
|
530
|
+
fileName?: string;
|
|
531
|
+
thumbUrl?: string;
|
|
532
|
+
percentage?: number;
|
|
517
533
|
};
|
|
518
534
|
/**
|
|
519
535
|
* 附件格式
|
|
@@ -528,18 +544,32 @@ declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
|
|
|
528
544
|
group: string;
|
|
529
545
|
id: string;
|
|
530
546
|
name: string;
|
|
531
|
-
size?: number
|
|
532
|
-
uid?: string
|
|
533
|
-
objectUrl?: string
|
|
534
|
-
isImage?: boolean
|
|
535
|
-
message?: string
|
|
536
|
-
deletable?: boolean
|
|
537
|
-
reupload?: boolean
|
|
538
|
-
fileName?: string
|
|
539
|
-
thumbUrl?: string
|
|
540
|
-
percentage?: number
|
|
547
|
+
size?: number;
|
|
548
|
+
uid?: string;
|
|
549
|
+
objectUrl?: string;
|
|
550
|
+
isImage?: boolean;
|
|
551
|
+
message?: string;
|
|
552
|
+
deletable?: boolean;
|
|
553
|
+
reupload?: boolean;
|
|
554
|
+
fileName?: string;
|
|
555
|
+
thumbUrl?: string;
|
|
556
|
+
percentage?: number;
|
|
541
557
|
}[];
|
|
542
558
|
|
|
559
|
+
/**
|
|
560
|
+
* 自然排序
|
|
561
|
+
* @param {UnDef<string>[] | UnDef<number>[]} arr - 数字或字符串数组
|
|
562
|
+
* @returns {UnDef<string>[] | UnDef<number>[]} - 排序后的数组
|
|
563
|
+
*/
|
|
564
|
+
declare const naturalSort: (arr: UnDef<string>[] | UnDef<number>[]) => UnDef<string>[] | UnDef<number>[];
|
|
565
|
+
/**
|
|
566
|
+
* 根据 key 自然排序
|
|
567
|
+
* @param arr - 数组
|
|
568
|
+
* @param {string} key - 键名
|
|
569
|
+
* @returns {any[]} - 排序后的数组
|
|
570
|
+
*/
|
|
571
|
+
declare const naturalSortBy: <T extends Record<string, UnDef<Numeric>>>(arr: T[], key: keyof T) => T[];
|
|
572
|
+
|
|
543
573
|
/**
|
|
544
574
|
* 检测变量类型
|
|
545
575
|
* @param {any} val 检测的目标
|
|
@@ -589,7 +619,7 @@ declare const isObject: (val: any) => val is Record<any, any>;
|
|
|
589
619
|
* 是否是数组
|
|
590
620
|
* @param {any} val 检测的目标
|
|
591
621
|
*/
|
|
592
|
-
declare const isArray: (val: any) => val is any
|
|
622
|
+
declare const isArray: (val: any) => val is Array<any>;
|
|
593
623
|
/**
|
|
594
624
|
* 是否是函数,但也有可能是Class
|
|
595
625
|
* @param {any} val 检测的目标
|
|
@@ -677,7 +707,7 @@ declare const isArrStr: (str: UnDef<string>) => boolean;
|
|
|
677
707
|
* ```
|
|
678
708
|
* @returns {boolean} boolean
|
|
679
709
|
*/
|
|
680
|
-
declare const isValidKey: (key: string | number | symbol, object: object) => key is
|
|
710
|
+
declare const isValidKey: (key: string | number | symbol, object: object) => key is keyof typeof object;
|
|
681
711
|
/**
|
|
682
712
|
* 是否是空值/空数组/空对象 null undefined '' [] {} Set Map
|
|
683
713
|
* @param val
|
|
@@ -685,30 +715,15 @@ declare const isValidKey: (key: string | number | symbol, object: object) => key
|
|
|
685
715
|
declare const isEmpty: (val: UnDef<Numeric | boolean | Record<any, any> | Array<any> | Set<any> | Map<any, any>>) => boolean;
|
|
686
716
|
|
|
687
717
|
/**
|
|
688
|
-
*
|
|
689
|
-
* @
|
|
690
|
-
*
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
*
|
|
695
|
-
* @param res
|
|
696
|
-
* @param code
|
|
697
|
-
*/
|
|
698
|
-
declare const isValidRes: (res: Res, code?: number) => boolean;
|
|
699
|
-
/**
|
|
700
|
-
* 校验接口数组返回内容
|
|
701
|
-
* @param res
|
|
702
|
-
* @param code
|
|
703
|
-
*/
|
|
704
|
-
declare const isValidArrRes: (res: Res<any[]>, code?: number) => boolean;
|
|
705
|
-
/**
|
|
706
|
-
* 校验接口分页返回内容
|
|
707
|
-
* @param res
|
|
708
|
-
* @param code
|
|
718
|
+
* 是否是[统一社会信用代码](https://zh.wikipedia.org/zh-cn/%E7%BB%9F%E4%B8%80%E7%A4%BE%E4%BC%9A%E4%BF%A1%E7%94%A8%E4%BB%A3%E7%A0%81)
|
|
719
|
+
* @example
|
|
720
|
+
* ```ts
|
|
721
|
+
* isUSCI('91350100M000100Y43') // true
|
|
722
|
+
* ```
|
|
723
|
+
* @param {UnDef<string>} val - 待校验的值
|
|
724
|
+
* @returns {boolean} 是否是统一社会信用代码
|
|
709
725
|
*/
|
|
710
|
-
declare const
|
|
711
|
-
|
|
726
|
+
declare const isUSCI: (val: UnDef<string>) => boolean;
|
|
712
727
|
/**
|
|
713
728
|
* 是否是中国手机号
|
|
714
729
|
* @param val
|
|
@@ -753,4 +768,29 @@ declare const nonASCII: (text: string) => boolean;
|
|
|
753
768
|
*/
|
|
754
769
|
declare const isValidFileType: (file: File, type: string) => boolean;
|
|
755
770
|
|
|
756
|
-
|
|
771
|
+
/**
|
|
772
|
+
* 校验接口返回code
|
|
773
|
+
* @param res
|
|
774
|
+
* @param code
|
|
775
|
+
*/
|
|
776
|
+
declare const isValidResCode: (res: Res, code?: number) => boolean;
|
|
777
|
+
/**
|
|
778
|
+
* 校验接口返回内容
|
|
779
|
+
* @param res
|
|
780
|
+
* @param code
|
|
781
|
+
*/
|
|
782
|
+
declare const isValidRes: (res: Res, code?: number) => boolean;
|
|
783
|
+
/**
|
|
784
|
+
* 校验接口数组返回内容
|
|
785
|
+
* @param res
|
|
786
|
+
* @param code
|
|
787
|
+
*/
|
|
788
|
+
declare const isValidArrRes: (res: Res<any[]>, code?: number) => boolean;
|
|
789
|
+
/**
|
|
790
|
+
* 校验接口分页返回内容
|
|
791
|
+
* @param res
|
|
792
|
+
* @param code
|
|
793
|
+
*/
|
|
794
|
+
declare const isValidPageRes: (res: PageRes, code?: number) => boolean;
|
|
795
|
+
|
|
796
|
+
export { type Dict, type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageReq, type PageRes, type PageResData, type PartialBy, type Res, type UnDef, type Undefinable, type VK, attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, currencyFmt, dateDuration, dateFmt, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, hideName, hidePhone, hideSurname, hideTail, hideThird, inBrowser, isArrStr, isArray, isBigInt, isBlob, isBoolean, isDate, isDef, isEmail, isEmpty, isError, isFile, isFunction, isIdCard, isJSONStr, isMap, isNull, isNumber, isNumeric, isObject, isPhone, isPromise, isRegExp, isSet, isString, isSymbol, isTel, isURL, isUSCI, isUndefined, isValidArrRes, isValidFileType, isValidKey, isValidPageRes, isValidRes, isValidResCode, isWeakMap, isWeakSet, jClear, jDebug, jError, jGroup, jGroupC, jGroupE, jInfo, jLog, jLogDedupe, jLogOnce, jTime, jTimeEnd, jWarn, kebab2Camel, kebab2Pascal, kebab2Snake, kebab2Title, naturalSort, naturalSortBy, nonASCII, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
|