@jhqn/utils-core 0.4.7 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +119 -119
  2. package/dist/index.js +13 -12
  3. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -97,140 +97,140 @@ interface HostEnv {
97
97
  * @returns {string} 转换后的字符串
98
98
  * @example snake2Kebab('hello_world') // hello_world => hello-world
99
99
  */
100
- declare const snake2Kebab: (str: string) => string;
100
+ export declare const snake2Kebab: (str: string) => string;
101
101
  /**
102
102
  * snake2Pascal
103
103
  * @param {string} str 字符串
104
104
  * @returns {string} 转换后的字符串
105
105
  * @example snake2Pascal('hello_world') // hello_world => HelloWorld
106
106
  */
107
- declare const snake2Pascal: (str: string) => string;
107
+ export declare const snake2Pascal: (str: string) => string;
108
108
  /**
109
109
  * snake2Camel
110
110
  * @param {string} str 字符串
111
111
  * @returns {string} 转换后的字符串
112
112
  * @example snake2Camel('hello_world') // hello_world => helloWorld
113
113
  */
114
- declare const snake2Camel: (str: string) => string;
114
+ export declare const snake2Camel: (str: string) => string;
115
115
  /**
116
116
  * snake2Title
117
117
  * @param {string} str 字符串
118
118
  * @returns {string} 转换后的字符串
119
119
  * @example snake2Title('hello_world') // hello_world => Hello World
120
120
  */
121
- declare const snake2Title: (str: string) => string;
121
+ export declare const snake2Title: (str: string) => string;
122
122
  /**
123
123
  * kebab2Snake
124
124
  * @param {string} str 字符串
125
125
  * @returns {string} 转换后的字符串
126
126
  * @example kebab2Snake('hello-world') // hello-world => hello_world
127
127
  */
128
- declare const kebab2Snake: (str: string) => string;
128
+ export declare const kebab2Snake: (str: string) => string;
129
129
  /**
130
130
  * kebab2Pascal
131
131
  * @param {string} str 字符串
132
132
  * @returns {string} 转换后的字符串
133
133
  * @example kebab2Pascal('hello-world') // hello-world => HelloWorld
134
134
  */
135
- declare const kebab2Pascal: (str: string) => string;
135
+ export declare const kebab2Pascal: (str: string) => string;
136
136
  /**
137
137
  * kebab2Camel
138
138
  * @param {string} str 字符串
139
139
  * @returns {string} 转换后的字符串
140
140
  * @example kebab2Camel('hello-world') // hello-world => helloWorld
141
141
  */
142
- declare const kebab2Camel: (str: string) => string;
142
+ export declare const kebab2Camel: (str: string) => string;
143
143
  /**
144
144
  * kebab2Title
145
145
  * @param {string} str 字符串
146
146
  * @returns {string} 转换后的字符串
147
147
  * @example kebab2Title('hello-world') // hello-world => Hello World
148
148
  */
149
- declare const kebab2Title: (str: string) => string;
149
+ export declare const kebab2Title: (str: string) => string;
150
150
  /**
151
151
  * pascal2Snake
152
152
  * @param {string} str 字符串
153
153
  * @returns {string} 转换后的字符串
154
154
  * @example pascal2Snake('HelloWorld') // HelloWorld => hello_world
155
155
  */
156
- declare const pascal2Snake: (str: string) => string;
156
+ export declare const pascal2Snake: (str: string) => string;
157
157
  /**
158
158
  * pascal2Kebab
159
159
  * @param {string} str 字符串
160
160
  * @returns {string} 转换后的字符串
161
161
  * @example pascal2Kebab('HelloWorld') // HelloWorld => hello-world
162
162
  */
163
- declare const pascal2Kebab: (str: string) => string;
163
+ export declare const pascal2Kebab: (str: string) => string;
164
164
  /**
165
165
  * pascal2Camel
166
166
  * @param {string} str 字符串
167
167
  * @returns {string} 转换后的字符串
168
168
  * @example pascal2Camel('HelloWorld') // HelloWorld => helloWorld
169
169
  */
170
- declare const pascal2Camel: (str: string) => string;
170
+ export declare const pascal2Camel: (str: string) => string;
171
171
  /**
172
172
  * pascal2Title
173
173
  * @param {string} str 字符串
174
174
  * @returns {string} 转换后的字符串
175
175
  * @example pascal2Title('HelloWorld') // HelloWorld => Hello World
176
176
  */
177
- declare const pascal2Title: (str: string) => string;
177
+ export declare const pascal2Title: (str: string) => string;
178
178
  /**
179
179
  * camel2Snake
180
180
  * @param {string} str 字符串
181
181
  * @returns {string} 转换后的字符串
182
182
  * @example camel2Snake('helloWorld') // helloWorld => hello_world
183
183
  */
184
- declare const camel2Snake: (str: string) => string;
184
+ export declare const camel2Snake: (str: string) => string;
185
185
  /**
186
186
  * camel2Kebab
187
187
  * @param {string} str 字符串
188
188
  * @returns {string} 转换后的字符串
189
189
  * @example camel2Kebab('helloWorld') // helloWorld => hello-world
190
190
  */
191
- declare const camel2Kebab: (str: string) => string;
191
+ export declare const camel2Kebab: (str: string) => string;
192
192
  /**
193
193
  * camel2Pascal
194
194
  * @param {string} str 字符串
195
195
  * @returns {string} 转换后的字符串
196
196
  * @example camel2Pascal('helloWorld') // helloWorld => HelloWorld
197
197
  */
198
- declare const camel2Pascal: (str: string) => string;
198
+ export declare const camel2Pascal: (str: string) => string;
199
199
  /**
200
200
  * camel2Title
201
201
  * @param {string} str 字符串
202
202
  * @returns {string} 转换后的字符串
203
203
  * @example camel2Title('helloWorld') // helloWorld => Hello World
204
204
  */
205
- declare const camel2Title: (str: string) => string;
205
+ export declare const camel2Title: (str: string) => string;
206
206
  /**
207
207
  * title2Snake
208
208
  * @param {string} str 字符串
209
209
  * @returns {string} 转换后的字符串
210
210
  * @example title2Snake('Hello World') // Hello World => hello_world
211
211
  */
212
- declare const title2Snake: (str: string) => string;
212
+ export declare const title2Snake: (str: string) => string;
213
213
  /**
214
214
  * title2Kebab
215
215
  * @param {string} str 字符串
216
216
  * @returns {string} 转换后的字符串
217
217
  * @example title2Kebab('Hello World') // Hello World => hello-world
218
218
  */
219
- declare const title2Kebab: (str: string) => string;
219
+ export declare const title2Kebab: (str: string) => string;
220
220
  /**
221
221
  * title2Pascal
222
222
  * @param {string} str 字符串
223
223
  * @returns {string} 转换后的字符串
224
224
  * @example title2Pascal('Hello World') // Hello World => HelloWorld
225
225
  */
226
- declare const title2Pascal: (str: string) => string;
226
+ export declare const title2Pascal: (str: string) => string;
227
227
  /**
228
228
  * title2Camel
229
229
  * @param {string} str 字符串
230
230
  * @returns {string} 转换后的字符串
231
231
  * @example title2Camel('Hello World') // Hello World => helloWorld
232
232
  */
233
- declare const title2Camel: (str: string) => string;
233
+ export declare const title2Camel: (str: string) => string;
234
234
  //#endregion
235
235
  //#region src/console/log-common.d.ts
236
236
  /**
@@ -238,65 +238,65 @@ declare const title2Camel: (str: string) => string;
238
238
  * only for development
239
239
  * @param {...any} args
240
240
  */
241
- declare const jLog: (...args: any[]) => void | (() => void);
241
+ export declare const jLog: (...args: any[]) => void | (() => void);
242
242
  /**
243
243
  * jade console.debug
244
244
  * @param {...any} args
245
245
  */
246
- declare const jDebug: (...args: any[]) => void;
246
+ export declare const jDebug: (...args: any[]) => void;
247
247
  /**
248
248
  * jade console.warn
249
249
  */
250
- declare const jWarn: (...args: any[]) => void;
250
+ export declare const jWarn: (...args: any[]) => void;
251
251
  /**
252
252
  * jade console.error
253
253
  */
254
- declare const jError: (...args: any[]) => void;
254
+ export declare const jError: (...args: any[]) => void;
255
255
  /**
256
256
  * jade console.info
257
257
  * @param {...any} args
258
258
  */
259
- declare const jInfo: (...args: any[]) => void;
259
+ export declare const jInfo: (...args: any[]) => void;
260
260
  /**
261
261
  * jade console.group
262
262
  */
263
- declare const jGroup: (...args: any[]) => void;
263
+ export declare const jGroup: (...args: any[]) => void;
264
264
  /**
265
265
  * jade console.groupCollapsed
266
266
  */
267
- declare const jGroupC: (...args: any[]) => void;
267
+ export declare const jGroupC: (...args: any[]) => void;
268
268
  /**
269
269
  * jade console.groupEnd
270
270
  */
271
- declare const jGroupE: () => void;
271
+ export declare const jGroupE: () => void;
272
272
  /**
273
273
  * jade console.time
274
274
  * @param str
275
275
  */
276
- declare const jTime: (str: string) => void;
276
+ export declare const jTime: (str: string) => void;
277
277
  /**
278
278
  * jade console.timeEnd
279
279
  * @param str
280
280
  */
281
- declare const jTimeEnd: (str: string) => void;
281
+ export declare const jTimeEnd: (str: string) => void;
282
282
  /**
283
283
  * jade console.clear
284
284
  */
285
- declare const jClear: () => void;
285
+ export declare const jClear: () => void;
286
286
  //#endregion
287
287
  //#region src/console/log-dedupe.d.ts
288
288
  /**
289
289
  * 不连续打印相同的值
290
290
  * @param args
291
291
  */
292
- declare const jLogDedupe: (...args: any[]) => void;
292
+ export declare const jLogDedupe: (...args: any[]) => void;
293
293
  //#endregion
294
294
  //#region src/console/log-once.d.ts
295
295
  /**
296
296
  * 只打印一次
297
297
  * @param args
298
298
  */
299
- declare const jLogOnce: (...args: any[]) => void;
299
+ export declare const jLogOnce: (...args: any[]) => void;
300
300
  //#endregion
301
301
  //#region src/desensitize.d.ts
302
302
  /**
@@ -312,7 +312,7 @@ declare const jLogOnce: (...args: any[]) => void;
312
312
  * hideMiddle('ABCDE') // 'A***E'
313
313
  * ```
314
314
  */
315
- declare const hideMiddle: (str: UnDef<string>) => string;
315
+ export declare const hideMiddle: (str: UnDef<string>) => string;
316
316
  /**
317
317
  * 隐藏首尾仅保留中间3分之1
318
318
  * @param {string} str 需要隐藏的字符串
@@ -326,7 +326,7 @@ declare const hideMiddle: (str: UnDef<string>) => string;
326
326
  * hideThird('ABCDE') // 'AB*DE'
327
327
  * ```
328
328
  */
329
- declare const hideThird: (str: UnDef<string>) => string;
329
+ export declare const hideThird: (str: UnDef<string>) => string;
330
330
  /**
331
331
  * 隐藏首部
332
332
  * @param {string} str 需要隐藏的字符串
@@ -340,7 +340,7 @@ declare const hideThird: (str: UnDef<string>) => string;
340
340
  * hideHead('ABC', 1) // '*BC'
341
341
  * ```
342
342
  */
343
- declare const hideHead: (str: UnDef<string>, count?: number) => string;
343
+ export declare const hideHead: (str: UnDef<string>, count?: number) => string;
344
344
  /**
345
345
  * 隐藏尾部
346
346
  * @param {string} str 需要隐藏的字符串
@@ -354,7 +354,7 @@ declare const hideHead: (str: UnDef<string>, count?: number) => string;
354
354
  * hideTail('ABC', 1) // 'AB*'
355
355
  * ```
356
356
  */
357
- declare const hideTail: (str: UnDef<string>, count?: number) => string;
357
+ export declare const hideTail: (str: UnDef<string>, count?: number) => string;
358
358
  /**
359
359
  * 隐藏手机号/座机号
360
360
  * @param {string} phone 手机号/座机号
@@ -366,7 +366,7 @@ declare const hideTail: (str: UnDef<string>, count?: number) => string;
366
366
  * hidePhone('(010)12345678') // '(010)****5678'
367
367
  * ```
368
368
  */
369
- declare const hidePhone: (phone: UnDef<string>) => string;
369
+ export declare const hidePhone: (phone: UnDef<string>) => string;
370
370
  /**
371
371
  * 隐藏身份证号
372
372
  * @param {string} cardNo 身份证号
@@ -378,7 +378,7 @@ declare const hidePhone: (phone: UnDef<string>) => string;
378
378
  * hideCardNo('33072319641008384x', false) // '3***23196410*****x'
379
379
  * ```
380
380
  */
381
- declare const hideCardNo: (cardNo: UnDef<string>, strong?: boolean) => string;
381
+ export declare const hideCardNo: (cardNo: UnDef<string>, strong?: boolean) => string;
382
382
  /**
383
383
  * 隐藏姓氏
384
384
  * @param {string} name 姓名
@@ -389,7 +389,7 @@ declare const hideCardNo: (cardNo: UnDef<string>, strong?: boolean) => string;
389
389
  * hideSurname('司马懿') // '*马懿'
390
390
  * ```
391
391
  */
392
- declare const hideSurname: (name: UnDef<string>) => string;
392
+ export declare const hideSurname: (name: UnDef<string>) => string;
393
393
  /**
394
394
  * 隐藏名字
395
395
  * @param {string} name 姓名
@@ -400,7 +400,7 @@ declare const hideSurname: (name: UnDef<string>) => string;
400
400
  * hideFirstName('司马懿') // '司马*'
401
401
  * ```
402
402
  */
403
- declare const hideFirstName: (name: UnDef<string>) => string;
403
+ export declare const hideFirstName: (name: UnDef<string>) => string;
404
404
  /**
405
405
  * 隐藏邮箱
406
406
  * @param {string} email 邮箱
@@ -410,7 +410,7 @@ declare const hideFirstName: (name: UnDef<string>) => string;
410
410
  * hideEmail('example@hotmail.com') // 'exam***@hotmail.com'
411
411
  * ```
412
412
  */
413
- declare const hideEmail: (email: UnDef<string>) => string;
413
+ export declare const hideEmail: (email: UnDef<string>) => string;
414
414
  /**
415
415
  * 隐藏银行卡号
416
416
  * @param {string} bankCard 银行卡号
@@ -420,28 +420,28 @@ declare const hideEmail: (email: UnDef<string>) => string;
420
420
  * hideBankCard('6222021001123456789') // '622202********6789'
421
421
  * ```
422
422
  */
423
- declare const hideBankCard: (bankCard: UnDef<string>) => string;
423
+ export declare const hideBankCard: (bankCard: UnDef<string>) => string;
424
424
  //#endregion
425
425
  //#region src/dom.d.ts
426
426
  /**
427
427
  * 判断是否是浏览器环境
428
428
  */
429
- declare const inBrowser: boolean;
429
+ export declare const inBrowser: boolean;
430
430
  /**
431
431
  * 等待一段时间
432
432
  * @param time
433
433
  */
434
- declare const waitTime: (time?: number) => Promise<unknown>;
434
+ export declare const waitTime: (time?: number) => Promise<unknown>;
435
435
  /**
436
436
  * 防止 iOS 因输入框字体小于16px 而在 focus 时页面缩放变大需要手动回正的情况。
437
437
  * iOS 10+ 允许 pinch-zoom, 即使 viewport 是不可伸缩的。
438
438
  * 只对这些浏览器添加额外规则
439
439
  */
440
- declare const fixiOSInputAutoZoomIn: () => void;
440
+ export declare const fixiOSInputAutoZoomIn: () => void;
441
441
  /**
442
442
  * 用户代理
443
443
  */
444
- declare const userAgent: string;
444
+ export declare const userAgent: string;
445
445
  /**
446
446
  * 获取宿主环境信息
447
447
  * @returns {HostEnv} 宿主环境信息
@@ -455,30 +455,30 @@ declare const userAgent: string;
455
455
  * hostEnv.zfb // 支付宝
456
456
  * hostEnv.mini // 小程序
457
457
  */
458
- declare const getHostEnv: () => HostEnv;
458
+ export declare const getHostEnv: () => HostEnv;
459
459
  /**
460
460
  * 获取当小时的时间戳的异或值的绝对值, 当小时内获取的值是唯一的
461
461
  */
462
- declare const getCodeOfHour: () => number;
462
+ export declare const getCodeOfHour: () => number;
463
463
  /**
464
464
  * 获取当天的时间戳的异或值的绝对值, 当天内获取的值是唯一的
465
465
  */
466
- declare const getCodeOfDate: () => number;
466
+ export declare const getCodeOfDate: () => number;
467
467
  /**
468
468
  * 获取当月的时间戳的异或值的绝对值, 当月内获取的值是唯一的
469
469
  */
470
- declare const getCodeOfMonth: () => number;
470
+ export declare const getCodeOfMonth: () => number;
471
471
  //#endregion
472
472
  //#region src/format/baseAttachUrl.d.ts
473
473
  /**
474
474
  * 设置文件基本路径
475
475
  * @param baseUrl
476
476
  */
477
- declare function setBaseAttachUrl(baseUrl: string): void;
477
+ export declare function setBaseAttachUrl(baseUrl: string): void;
478
478
  /**
479
479
  * 获取文件基本路径
480
480
  */
481
- declare function getBaseAttachUrl(): string;
481
+ export declare function getBaseAttachUrl(): string;
482
482
  //#endregion
483
483
  //#region src/format/core.d.ts
484
484
  /**
@@ -489,7 +489,7 @@ declare function getBaseAttachUrl(): string;
489
489
  * @returns {Nullable<T>} 解析后的对象
490
490
  * @deprecated 请使用 `parseJSON`
491
491
  */
492
- declare function parseToJSON<T = any>(str: string, reviverFn?: (this: any, key: string, value: any) => any): Nullable<T>;
492
+ export declare function parseToJSON<T = any>(str: string, reviverFn?: (this: any, key: string, value: any) => any): Nullable<T>;
493
493
  /**
494
494
  * JSON 字符串转对象
495
495
  * @alias parseToJSON
@@ -498,33 +498,33 @@ declare function parseToJSON<T = any>(str: string, reviverFn?: (this: any, key:
498
498
  * @param {(this: any, key: string, value: any) => any} reviverFn - 解析函数
499
499
  * @returns {Nullable<T>} 解析后的对象
500
500
  */
501
- declare function parseJSON<T = any>(str: string, reviverFn?: (this: any, key: string, value: any) => any): Nullable<T>;
501
+ export declare function parseJSON<T = any>(str: string, reviverFn?: (this: any, key: string, value: any) => any): Nullable<T>;
502
502
  /**
503
503
  * 对象转 JSON 字符串
504
504
  * @param {any} value - 对象
505
505
  * @param {(this: any, key: string, value: any) => any} replacerFn - 替换函数
506
506
  * @returns {string} JSON 字符串
507
507
  */
508
- declare function stringifyJSON(value: any, replacerFn?: (this: any, key: string, value: any) => any): string;
508
+ export declare function stringifyJSON(value: any, replacerFn?: (this: any, key: string, value: any) => any): string;
509
509
  /**
510
510
  * JSON.stringify() second param
511
511
  * @param _key
512
512
  * @param value
513
513
  */
514
- declare function replacer(_key: any, value: any): any;
514
+ export declare function replacer(_key: any, value: any): any;
515
515
  /**
516
516
  * JSON.parse() second param
517
517
  * @param _key
518
518
  * @param value
519
519
  */
520
- declare function reviver(_key: any, value: any): any;
520
+ export declare function reviver(_key: any, value: any): any;
521
521
  /**
522
522
  * 过滤obj中仅包括keys的部分
523
523
  * @param {Record<string,any>} obj 对象
524
524
  * @param {string[]} keys 属性
525
525
  * @param {boolean} reverse 为true时过滤取反
526
526
  */
527
- declare const filterObj: (obj: Record<string, any>, keys: string[], reverse?: boolean) => {
527
+ export declare const filterObj: (obj: Record<string, any>, keys: string[], reverse?: boolean) => {
528
528
  [k: string]: any;
529
529
  };
530
530
  //#endregion
@@ -533,7 +533,7 @@ declare const filterObj: (obj: Record<string, any>, keys: string[], reverse?: bo
533
533
  * 千位分隔符
534
534
  * @param num
535
535
  */
536
- declare const toThousands: (num: number) => string;
536
+ export declare const toThousands: (num: number) => string;
537
537
  /**
538
538
  * 货币格式化
539
539
  * @example
@@ -543,7 +543,7 @@ declare const toThousands: (num: number) => string;
543
543
  * @param {number | string | bigint} currency - 金额
544
544
  * @param {number} [maximumFractionDigits] - 最多小数位数
545
545
  */
546
- declare const currencyFmt: (currency: UnDef<Numeric | bigint>, maximumFractionDigits?: number) => string;
546
+ export declare const currencyFmt: (currency: UnDef<Numeric | bigint>, maximumFractionDigits?: number) => string;
547
547
  //#endregion
548
548
  //#region src/format/dayjs.d.ts
549
549
  /**
@@ -557,13 +557,13 @@ declare const currencyFmt: (currency: UnDef<Numeric | bigint>, maximumFractionDi
557
557
  * @param {string} [format = "datetime"] 格式化pattern
558
558
  * @returns {string} 格式化后的时间
559
559
  */
560
- declare const dateFmt: (date: ConfigType, format?: string | "date" | "datetime") => string;
560
+ export declare const dateFmt: (date: ConfigType, format?: string | "date" | "datetime") => string;
561
561
  /**
562
562
  * 格式化时间间隔
563
563
  * @param {import('dayjs').ConfigType} start 开始时间
564
564
  * @param {import('dayjs').ConfigType} end 结束时间
565
565
  */
566
- declare const dateDuration: (start: ConfigType, end: ConfigType) => string;
566
+ export declare const dateDuration: (start: ConfigType, end: ConfigType) => string;
567
567
  //#endregion
568
568
  //#region types/upload.d.ts
569
569
  type VantUploadFileStatus = '' | 'uploading' | 'done' | 'failed';
@@ -600,12 +600,12 @@ interface Resource {
600
600
  * 获取文件完整地址
601
601
  * @param url
602
602
  */
603
- declare const resUrl: (url: Undefinable<string>) => string | undefined;
603
+ export declare const resUrl: (url: Undefinable<string>) => string | undefined;
604
604
  /**
605
605
  * 统一文件字段内容
606
606
  * @param resource
607
607
  */
608
- declare const recoverFile: (resource: Resource) => {
608
+ export declare const recoverFile: (resource: Resource) => {
609
609
  url: string | undefined;
610
610
  content: string | undefined;
611
611
  uri: string;
@@ -629,7 +629,7 @@ declare const recoverFile: (resource: Resource) => {
629
629
  * 附件格式
630
630
  * @param data
631
631
  */
632
- declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
632
+ export declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
633
633
  url: string | undefined;
634
634
  content: string | undefined;
635
635
  uri: string;
@@ -656,150 +656,150 @@ declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
656
656
  * @param {UnDef<string>[] | UnDef<number>[]} arr - 数字或字符串数组
657
657
  * @returns {UnDef<string>[] | UnDef<number>[]} - 排序后的数组
658
658
  */
659
- declare const naturalSort: (arr: UnDef<string>[] | UnDef<number>[]) => UnDef<string>[] | UnDef<number>[];
659
+ export declare const naturalSort: (arr: UnDef<string>[] | UnDef<number>[]) => UnDef<string>[] | UnDef<number>[];
660
660
  /**
661
661
  * 根据 key 自然排序
662
662
  * @param arr - 数组
663
663
  * @param {string} key - 键名
664
664
  * @returns {any[]} - 排序后的数组
665
665
  */
666
- declare const naturalSortBy: <T extends Record<string, UnDef<Numeric>>>(arr: T[], key: keyof T) => T[];
666
+ export declare const naturalSortBy: <T extends Record<string, UnDef<Numeric>>>(arr: T[], key: keyof T) => T[];
667
667
  //#endregion
668
668
  //#region src/mock.d.ts
669
- declare const getMockData: <T>(data: T, code?: number, message?: string) => Res<T>;
670
- declare const getMockDataList: <T>(data: T[], total: number, code?: number, message?: string, options?: Partial<PageResData<T>>) => PageRes<T>;
669
+ export declare const getMockData: <T>(data: T, code?: number, message?: string) => Res<T>;
670
+ export declare const getMockDataList: <T>(data: T[], total: number, code?: number, message?: string, options?: Partial<PageResData<T>>) => PageRes<T>;
671
671
  //#endregion
672
672
  //#region src/validate/core.d.ts
673
673
  /**
674
674
  * 检测变量类型
675
675
  * @param {any} val 检测的目标
676
676
  */
677
- declare const getVariableType: (val: any) => string;
677
+ export declare const getVariableType: (val: any) => string;
678
678
  /**
679
679
  * 是否是数字
680
680
  * @param {any} val 检测的目标
681
681
  */
682
- declare const isNumber: (val: any) => val is number;
682
+ export declare const isNumber: (val: any) => val is number;
683
683
  /**
684
684
  * 是否是任意精度整数
685
685
  * @param {any} val 检测的目标
686
686
  */
687
- declare const isBigInt: (val: any) => val is bigint;
687
+ export declare const isBigInt: (val: any) => val is bigint;
688
688
  /**
689
689
  * 是否是字符串
690
690
  * @param {any} val 检测的目标
691
691
  */
692
- declare const isString: (val: any) => val is string;
692
+ export declare const isString: (val: any) => val is string;
693
693
  /**
694
694
  * 是否是布尔值
695
695
  * @param {any} val 检测的目标
696
696
  */
697
- declare const isBoolean: (val: any) => val is boolean;
697
+ export declare const isBoolean: (val: any) => val is boolean;
698
698
  /**
699
699
  * 是否是null
700
700
  * @param {any} val 检测的目标
701
701
  */
702
- declare const isNull: (val: any) => val is null;
702
+ export declare const isNull: (val: any) => val is null;
703
703
  /**
704
704
  * 是否是undefined
705
705
  * @param {any} val 检测的目标
706
706
  */
707
- declare const isUndefined: (val: any) => val is undefined;
707
+ export declare const isUndefined: (val: any) => val is undefined;
708
708
  /**
709
709
  * 是否是symbol
710
710
  * @param {any} val 检测的目标
711
711
  */
712
- declare const isSymbol: (val: any) => val is symbol;
712
+ export declare const isSymbol: (val: any) => val is symbol;
713
713
  /**
714
714
  * 是否是对象
715
715
  * @param {any} val 检测的目标
716
716
  */
717
- declare const isObject: (val: any) => val is Record<any, any>;
717
+ export declare const isObject: (val: any) => val is Record<any, any>;
718
718
  /**
719
719
  * 是否是数组
720
720
  * @param {any} val 检测的目标
721
721
  */
722
- declare const isArray: (val: any) => val is Array<any>;
722
+ export declare const isArray: (val: any) => val is Array<any>;
723
723
  /**
724
724
  * 是否是函数,但也有可能是Class
725
725
  * @param {any} val 检测的目标
726
726
  */
727
- declare const isFunction: (val: any) => val is Function;
727
+ export declare const isFunction: (val: any) => val is Function;
728
728
  /**
729
729
  * 是否是纯函数(不包含 Class,含原生构造函数如 Date、Array 等)
730
730
  * @param {any} val 检测的目标
731
731
  */
732
- declare const isPureFunction: (val: any) => val is Function;
732
+ export declare const isPureFunction: (val: any) => val is Function;
733
733
  /**
734
734
  * 是否是日期
735
735
  * @param {any} val 检测的目标
736
736
  */
737
- declare const isDate: (val: any) => val is Date;
737
+ export declare const isDate: (val: any) => val is Date;
738
738
  /**
739
739
  * 是否是正则
740
740
  * @param {any} val 检测的目标
741
741
  */
742
- declare const isRegExp: (val: any) => val is RegExp;
742
+ export declare const isRegExp: (val: any) => val is RegExp;
743
743
  /**
744
744
  * 是否是期望(Promise)
745
745
  * @param {any} val 检测的目标
746
746
  */
747
- declare const isPromise: (val: any) => val is Promise<any>;
747
+ export declare const isPromise: (val: any) => val is Promise<any>;
748
748
  /**
749
749
  * 是否是集合(Set)
750
750
  * @param {any} val 检测的目标
751
751
  */
752
- declare const isSet: (val: any) => val is Set<any>;
752
+ export declare const isSet: (val: any) => val is Set<any>;
753
753
  /**
754
754
  * 是否是映射(Map)
755
755
  * @param {any} val 检测的目标
756
756
  */
757
- declare const isMap: (val: any) => val is Map<any, any>;
757
+ export declare const isMap: (val: any) => val is Map<any, any>;
758
758
  /**
759
759
  * 是否是弱集合(WeakSet)
760
760
  * @param {any} val 检测的目标
761
761
  */
762
- declare const isWeakSet: (val: any) => val is WeakSet<any>;
762
+ export declare const isWeakSet: (val: any) => val is WeakSet<any>;
763
763
  /**
764
764
  * 是否是弱映射(WeakMap)
765
765
  * @param {any} val 检测的目标
766
766
  */
767
- declare const isWeakMap: (val: any) => val is WeakMap<any, any>;
767
+ export declare const isWeakMap: (val: any) => val is WeakMap<any, any>;
768
768
  /**
769
769
  * 是否是File
770
770
  * @param {any} val 检测的目标
771
771
  */
772
- declare const isFile: (val: any) => val is File;
772
+ export declare const isFile: (val: any) => val is File;
773
773
  /**
774
774
  * 是否是Blob
775
775
  * @param {any} val 检测的目标
776
776
  */
777
- declare const isBlob: (val: any) => val is Blob;
777
+ export declare const isBlob: (val: any) => val is Blob;
778
778
  /**
779
779
  * 是否是URL
780
780
  * @param {any} val 检测的目标
781
781
  */
782
- declare const isURL: (val: any) => val is URL;
782
+ export declare const isURL: (val: any) => val is URL;
783
783
  /**
784
784
  * 是否是错误(Error)
785
785
  * @param {any} val 检测的目标
786
786
  */
787
- declare const isError: (val: any) => val is Error;
787
+ export declare const isError: (val: any) => val is Error;
788
788
  /**
789
789
  * 是否既不是 null 也不是 undefined
790
790
  * @param {any} val 检测的目标
791
791
  */
792
- declare const isDef: <T>(val: T) => val is NonNullable<T>;
792
+ export declare const isDef: <T>(val: T) => val is NonNullable<T>;
793
793
  /**
794
794
  * 判断是否合法JSON字符串
795
795
  * @param str
796
796
  */
797
- declare const isJSONStr: (str: UnDef<string>) => boolean;
797
+ export declare const isJSONStr: (str: UnDef<string>) => boolean;
798
798
  /**
799
799
  * 判断是否合法JSON数组字符串
800
800
  * @param str
801
801
  */
802
- declare const isArrStr: (str: UnDef<string>) => boolean;
802
+ export declare const isArrStr: (str: UnDef<string>) => boolean;
803
803
  /**
804
804
  * 判断是否有效的key
805
805
  * @param {string | number | symbol} key 键名
@@ -812,21 +812,21 @@ declare const isArrStr: (str: UnDef<string>) => boolean;
812
812
  * ```
813
813
  * @returns {boolean} boolean
814
814
  */
815
- declare const isValidKey: (key: string | number | symbol, object: object) => key is keyof typeof object;
815
+ export declare const isValidKey: (key: string | number | symbol, object: object) => key is keyof typeof object;
816
816
  /**
817
817
  * 是否是空值/空数组/空对象 null undefined '' [] {} Set Map
818
818
  * @param val
819
819
  */
820
- declare const isEmpty: (val: UnDef<Numeric | boolean | Record<any, any> | Array<any> | Set<any> | Map<any, any>>) => boolean;
820
+ export declare const isEmpty: (val: UnDef<Numeric | boolean | Record<any, any> | Array<any> | Set<any> | Map<any, any>>) => boolean;
821
821
  //#endregion
822
822
  //#region src/validate/form.d.ts
823
- declare const cnPhoneRE: RegExp;
824
- declare const cnTelRE: RegExp;
825
- declare const cnTelRE2: RegExp;
826
- declare const cnUSCIRE: RegExp;
827
- declare const cnIdCard15Re: RegExp;
828
- declare const cnIdCard18Re: RegExp;
829
- declare const emailRE: RegExp;
823
+ export declare const cnPhoneRE: RegExp;
824
+ export declare const cnTelRE: RegExp;
825
+ export declare const cnTelRE2: RegExp;
826
+ export declare const cnUSCIRE: RegExp;
827
+ export declare const cnIdCard15Re: RegExp;
828
+ export declare const cnIdCard18Re: RegExp;
829
+ export declare const emailRE: RegExp;
830
830
  /**
831
831
  * 是否是[统一社会信用代码](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)
832
832
  * @example
@@ -836,50 +836,50 @@ declare const emailRE: RegExp;
836
836
  * @param {UnDef<string>} val - 待校验的值
837
837
  * @returns {boolean} 是否是统一社会信用代码
838
838
  */
839
- declare const isUSCI: (val: UnDef<string>) => boolean;
839
+ export declare const isUSCI: (val: UnDef<string>) => boolean;
840
840
  /**
841
841
  * 是否是中国手机号
842
842
  * @param val
843
843
  */
844
- declare const isPhone: (val: UnDef<Numeric>) => boolean;
844
+ export declare const isPhone: (val: UnDef<Numeric>) => boolean;
845
845
  /**
846
846
  * 是否是中国座机号
847
847
  * @param val
848
848
  */
849
- declare const isTel: (val: UnDef<Numeric>) => boolean;
849
+ export declare const isTel: (val: UnDef<Numeric>) => boolean;
850
850
  /**
851
851
  * 是否是邮箱
852
852
  * @param val
853
853
  */
854
- declare const isEmail: (val: UnDef<string>) => boolean;
854
+ export declare const isEmail: (val: UnDef<string>) => boolean;
855
855
  /**
856
856
  * 是否是身份证
857
857
  * @param {string|null|undefined} val 身份证号
858
858
  * @param {boolean} compatible 兼容15位
859
859
  */
860
- declare const isIdCard: (val: UnDef<string>, compatible?: boolean) => boolean;
860
+ export declare const isIdCard: (val: UnDef<string>, compatible?: boolean) => boolean;
861
861
  /**
862
862
  * 是否是数字或字符
863
863
  * @param val
864
864
  */
865
- declare const isNumeric: (val: UnDef<Numeric>) => val is string;
865
+ export declare const isNumeric: (val: UnDef<Numeric>) => val is string;
866
866
  /**
867
867
  * 是否是需要的图片格式
868
868
  * @param ext
869
869
  */
870
- declare const checkImg: (ext?: string) => boolean;
870
+ export declare const checkImg: (ext?: string) => boolean;
871
871
  /**
872
872
  * 包含非ASCII字符
873
873
  * @param text
874
874
  */
875
- declare const nonASCII: (text: string) => boolean;
875
+ export declare const nonASCII: (text: string) => boolean;
876
876
  /**
877
877
  * 校验文件类型
878
878
  * 1. XXX/YYY 2. .xxx 3. XXX/* 4.*
879
879
  * @param {File} file 需要校验的文件
880
880
  * @param {string} type 文件类型, 与input.accept一致
881
881
  */
882
- declare const isValidFileType: (file: File, type: string) => boolean;
882
+ export declare const isValidFileType: (file: File, type: string) => boolean;
883
883
  //#endregion
884
884
  //#region src/validate/request.d.ts
885
885
  /**
@@ -887,24 +887,24 @@ declare const isValidFileType: (file: File, type: string) => boolean;
887
887
  * @param res
888
888
  * @param code
889
889
  */
890
- declare const isValidResCode: (res: Res, code?: number) => boolean;
890
+ export declare const isValidResCode: (res: Res, code?: number) => boolean;
891
891
  /**
892
892
  * 校验接口返回内容
893
893
  * @param res
894
894
  * @param code
895
895
  */
896
- declare const isValidRes: (res: Res, code?: number) => boolean;
896
+ export declare const isValidRes: (res: Res, code?: number) => boolean;
897
897
  /**
898
898
  * 校验接口数组返回内容
899
899
  * @param res
900
900
  * @param code
901
901
  */
902
- declare const isValidArrRes: (res: Res<any[]>, code?: number) => boolean;
902
+ export declare const isValidArrRes: (res: Res<any[]>, code?: number) => boolean;
903
903
  /**
904
904
  * 校验接口分页返回内容
905
905
  * @param res
906
906
  * @param code
907
907
  */
908
- declare const isValidPageRes: (res: PageRes, code?: number) => boolean;
908
+ export declare const isValidPageRes: (res: PageRes, code?: number) => boolean;
909
909
  //#endregion
910
- export { type Dayjs, type Dict, type HostEnv, 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, cnIdCard15Re, cnIdCard18Re, cnPhoneRE, cnTelRE, cnTelRE2, cnUSCIRE, currencyFmt, dateDuration, dateFmt, dayjs, emailRE, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, getMockData, getMockDataList, getVariableType, hideBankCard, hideCardNo, hideEmail, hideFirstName, hideHead, hideMiddle, 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, isPureFunction, 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, parseJSON, parseToJSON, pascal2Camel, pascal2Kebab, pascal2Snake, pascal2Title, recoverFile, replacer, resUrl, reviver, setBaseAttachUrl, snake2Camel, snake2Kebab, snake2Pascal, snake2Title, stringifyJSON, title2Camel, title2Kebab, title2Pascal, title2Snake, toThousands, userAgent, waitTime };
910
+ export { type Dayjs, type Dict, type HostEnv, type MaybeArray, type NullOrUndefinable, type Nullable, type Numeric, type PageReq, type PageRes, type PageResData, type PartialBy, type Res, type UnDef, type Undefinable, type VK, dayjs };
package/dist/index.js CHANGED
@@ -933,18 +933,19 @@ const attachFmt = (data) => {
933
933
  const prototype = Object.prototype.toString.call(data);
934
934
  if (!data) attachList = [];
935
935
  else if (isArray(data)) attachList = data.filter(Boolean);
936
- else if (typeof data === "string") if (isArrStr(data)) attachList = (parseJSON(data) || []).filter(Boolean);
937
- else {
938
- const jsonData = parseJSON(data);
939
- if (Object.prototype.toString.call(jsonData) === "[object Object]") attachList = [jsonData].filter(Boolean);
940
- else attachList = [{
941
- id: data,
942
- name: "name",
943
- uri: data,
944
- group: "default"
945
- }];
946
- }
947
- else if (prototype === "[object Object]") attachList = [data];
936
+ else if (typeof data === "string") {
937
+ if (isArrStr(data)) attachList = (parseJSON(data) || []).filter(Boolean);
938
+ else {
939
+ const jsonData = parseJSON(data);
940
+ if (Object.prototype.toString.call(jsonData) === "[object Object]") attachList = [jsonData].filter(Boolean);
941
+ else attachList = [{
942
+ id: data,
943
+ name: "name",
944
+ uri: data,
945
+ group: "default"
946
+ }];
947
+ }
948
+ } else if (prototype === "[object Object]") attachList = [data];
948
949
  return attachList.map(recoverFile);
949
950
  };
950
951
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jhqn/utils-core",
3
- "version": "0.4.7",
3
+ "version": "0.6.0",
4
4
  "keywords": [
5
5
  "jade",
6
6
  "utils"
@@ -13,7 +13,7 @@
13
13
  "author": "jade-gjz <jiangang.zhang@jaderd.com>",
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/jaderd-jh/utils",
16
+ "url": "git+https://github.com/jaderd-jh/utils.git",
17
17
  "directory": "packages/core"
18
18
  },
19
19
  "files": [
@@ -33,7 +33,7 @@
33
33
  }
34
34
  },
35
35
  "dependencies": {
36
- "dayjs": "^1.11.21",
36
+ "dayjs": "^1.11.23",
37
37
  "detect-browser-es": "0.1.1"
38
38
  },
39
39
  "scripts": {