@jhqn/utils-core 0.0.3 → 0.2.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.
- package/dist/index.d.ts +114 -94
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +6 -10
- package/dist/index.cjs +0 -611
- package/dist/index.d.cts +0 -886
- package/dist/index.d.mts +0 -886
- package/dist/index.mjs +0 -484
package/dist/index.d.mts
DELETED
|
@@ -1,886 +0,0 @@
|
|
|
1
|
-
/// <reference types="dayjs/plugin/localeData" />
|
|
2
|
-
/// <reference types="dayjs/plugin/duration" />
|
|
3
|
-
/// <reference types="dayjs/plugin/relativeTime" />
|
|
4
|
-
/// <reference types="dayjs/plugin/customParseFormat" />
|
|
5
|
-
/// <reference types="dayjs/plugin/objectSupport" />
|
|
6
|
-
import { ConfigType } from 'dayjs';
|
|
7
|
-
export { Dayjs, default as dayjs } from 'dayjs';
|
|
8
|
-
export { detect } from 'detect-browser';
|
|
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
|
-
|
|
63
|
-
interface HostEnv {
|
|
64
|
-
/**
|
|
65
|
-
* 是否是浙里办
|
|
66
|
-
*/
|
|
67
|
-
readonly zlb: boolean
|
|
68
|
-
/**
|
|
69
|
-
* 是否是专有钉
|
|
70
|
-
*/
|
|
71
|
-
readonly zyd: boolean
|
|
72
|
-
/**
|
|
73
|
-
* 是否是浙政钉
|
|
74
|
-
*/
|
|
75
|
-
readonly zzd: boolean
|
|
76
|
-
/**
|
|
77
|
-
* 是否是钉钉/专有钉/浙政钉
|
|
78
|
-
*/
|
|
79
|
-
readonly dd: boolean
|
|
80
|
-
/**
|
|
81
|
-
* 是否是微信
|
|
82
|
-
*/
|
|
83
|
-
readonly wx: boolean
|
|
84
|
-
/**
|
|
85
|
-
* 是否是支付宝
|
|
86
|
-
*/
|
|
87
|
-
readonly zfb: boolean
|
|
88
|
-
/**
|
|
89
|
-
* 是否是小程序
|
|
90
|
-
*/
|
|
91
|
-
readonly mini: boolean
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* snake2Kebab
|
|
96
|
-
* @param {string} str 字符串
|
|
97
|
-
* @returns {string} 转换后的字符串
|
|
98
|
-
* @example snake2Kebab('hello_world') // hello_world => hello-world
|
|
99
|
-
*/
|
|
100
|
-
declare const snake2Kebab: (str: string) => string;
|
|
101
|
-
/**
|
|
102
|
-
* snake2Pascal
|
|
103
|
-
* @param {string} str 字符串
|
|
104
|
-
* @returns {string} 转换后的字符串
|
|
105
|
-
* @example snake2Pascal('hello_world') // hello_world => HelloWorld
|
|
106
|
-
*/
|
|
107
|
-
declare const snake2Pascal: (str: string) => string;
|
|
108
|
-
/**
|
|
109
|
-
* snake2Camel
|
|
110
|
-
* @param {string} str 字符串
|
|
111
|
-
* @returns {string} 转换后的字符串
|
|
112
|
-
* @example snake2Camel('hello_world') // hello_world => helloWorld
|
|
113
|
-
*/
|
|
114
|
-
declare const snake2Camel: (str: string) => string;
|
|
115
|
-
/**
|
|
116
|
-
* snake2Title
|
|
117
|
-
* @param {string} str 字符串
|
|
118
|
-
* @returns {string} 转换后的字符串
|
|
119
|
-
* @example snake2Title('hello_world') // hello_world => Hello World
|
|
120
|
-
*/
|
|
121
|
-
declare const snake2Title: (str: string) => string;
|
|
122
|
-
/**
|
|
123
|
-
* kebab2Snake
|
|
124
|
-
* @param {string} str 字符串
|
|
125
|
-
* @returns {string} 转换后的字符串
|
|
126
|
-
* @example kebab2Snake('hello-world') // hello-world => hello_world
|
|
127
|
-
*/
|
|
128
|
-
declare const kebab2Snake: (str: string) => string;
|
|
129
|
-
/**
|
|
130
|
-
* kebab2Pascal
|
|
131
|
-
* @param {string} str 字符串
|
|
132
|
-
* @returns {string} 转换后的字符串
|
|
133
|
-
* @example kebab2Pascal('hello-world') // hello-world => HelloWorld
|
|
134
|
-
*/
|
|
135
|
-
declare const kebab2Pascal: (str: string) => string;
|
|
136
|
-
/**
|
|
137
|
-
* kebab2Camel
|
|
138
|
-
* @param {string} str 字符串
|
|
139
|
-
* @returns {string} 转换后的字符串
|
|
140
|
-
* @example kebab2Camel('hello-world') // hello-world => helloWorld
|
|
141
|
-
*/
|
|
142
|
-
declare const kebab2Camel: (str: string) => string;
|
|
143
|
-
/**
|
|
144
|
-
* kebab2Title
|
|
145
|
-
* @param {string} str 字符串
|
|
146
|
-
* @returns {string} 转换后的字符串
|
|
147
|
-
* @example kebab2Title('hello-world') // hello-world => Hello World
|
|
148
|
-
*/
|
|
149
|
-
declare const kebab2Title: (str: string) => string;
|
|
150
|
-
/**
|
|
151
|
-
* pascal2Snake
|
|
152
|
-
* @param {string} str 字符串
|
|
153
|
-
* @returns {string} 转换后的字符串
|
|
154
|
-
* @example pascal2Snake('HelloWorld') // HelloWorld => hello_world
|
|
155
|
-
*/
|
|
156
|
-
declare const pascal2Snake: (str: string) => string;
|
|
157
|
-
/**
|
|
158
|
-
* pascal2Kebab
|
|
159
|
-
* @param {string} str 字符串
|
|
160
|
-
* @returns {string} 转换后的字符串
|
|
161
|
-
* @example pascal2Kebab('HelloWorld') // HelloWorld => hello-world
|
|
162
|
-
*/
|
|
163
|
-
declare const pascal2Kebab: (str: string) => string;
|
|
164
|
-
/**
|
|
165
|
-
* pascal2Camel
|
|
166
|
-
* @param {string} str 字符串
|
|
167
|
-
* @returns {string} 转换后的字符串
|
|
168
|
-
* @example pascal2Camel('HelloWorld') // HelloWorld => helloWorld
|
|
169
|
-
*/
|
|
170
|
-
declare const pascal2Camel: (str: string) => string;
|
|
171
|
-
/**
|
|
172
|
-
* pascal2Title
|
|
173
|
-
* @param {string} str 字符串
|
|
174
|
-
* @returns {string} 转换后的字符串
|
|
175
|
-
* @example pascal2Title('HelloWorld') // HelloWorld => Hello World
|
|
176
|
-
*/
|
|
177
|
-
declare const pascal2Title: (str: string) => string;
|
|
178
|
-
/**
|
|
179
|
-
* camel2Snake
|
|
180
|
-
* @param {string} str 字符串
|
|
181
|
-
* @returns {string} 转换后的字符串
|
|
182
|
-
* @example camel2Snake('helloWorld') // helloWorld => hello_world
|
|
183
|
-
*/
|
|
184
|
-
declare const camel2Snake: (str: string) => string;
|
|
185
|
-
/**
|
|
186
|
-
* camel2Kebab
|
|
187
|
-
* @param {string} str 字符串
|
|
188
|
-
* @returns {string} 转换后的字符串
|
|
189
|
-
* @example camel2Kebab('helloWorld') // helloWorld => hello-world
|
|
190
|
-
*/
|
|
191
|
-
declare const camel2Kebab: (str: string) => string;
|
|
192
|
-
/**
|
|
193
|
-
* camel2Pascal
|
|
194
|
-
* @param {string} str 字符串
|
|
195
|
-
* @returns {string} 转换后的字符串
|
|
196
|
-
* @example camel2Pascal('helloWorld') // helloWorld => HelloWorld
|
|
197
|
-
*/
|
|
198
|
-
declare const camel2Pascal: (str: string) => string;
|
|
199
|
-
/**
|
|
200
|
-
* camel2Title
|
|
201
|
-
* @param {string} str 字符串
|
|
202
|
-
* @returns {string} 转换后的字符串
|
|
203
|
-
* @example camel2Title('helloWorld') // helloWorld => Hello World
|
|
204
|
-
*/
|
|
205
|
-
declare const camel2Title: (str: string) => string;
|
|
206
|
-
/**
|
|
207
|
-
* title2Snake
|
|
208
|
-
* @param {string} str 字符串
|
|
209
|
-
* @returns {string} 转换后的字符串
|
|
210
|
-
* @example title2Snake('Hello World') // Hello World => hello_world
|
|
211
|
-
*/
|
|
212
|
-
declare const title2Snake: (str: string) => string;
|
|
213
|
-
/**
|
|
214
|
-
* title2Kebab
|
|
215
|
-
* @param {string} str 字符串
|
|
216
|
-
* @returns {string} 转换后的字符串
|
|
217
|
-
* @example title2Kebab('Hello World') // Hello World => hello-world
|
|
218
|
-
*/
|
|
219
|
-
declare const title2Kebab: (str: string) => string;
|
|
220
|
-
/**
|
|
221
|
-
* title2Pascal
|
|
222
|
-
* @param {string} str 字符串
|
|
223
|
-
* @returns {string} 转换后的字符串
|
|
224
|
-
* @example title2Pascal('Hello World') // Hello World => HelloWorld
|
|
225
|
-
*/
|
|
226
|
-
declare const title2Pascal: (str: string) => string;
|
|
227
|
-
/**
|
|
228
|
-
* title2Camel
|
|
229
|
-
* @param {string} str 字符串
|
|
230
|
-
* @returns {string} 转换后的字符串
|
|
231
|
-
* @example title2Camel('Hello World') // Hello World => helloWorld
|
|
232
|
-
*/
|
|
233
|
-
declare const title2Camel: (str: string) => string;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* jade console.log
|
|
237
|
-
* only for development
|
|
238
|
-
* @param {...any} args
|
|
239
|
-
*/
|
|
240
|
-
declare const jLog: (...args: any[]) => void | (() => void);
|
|
241
|
-
/**
|
|
242
|
-
* jade console.debug
|
|
243
|
-
* @param {...any} args
|
|
244
|
-
*/
|
|
245
|
-
declare const jDebug: (...args: any[]) => void;
|
|
246
|
-
/**
|
|
247
|
-
* jade console.warn
|
|
248
|
-
*/
|
|
249
|
-
declare const jWarn: (...args: any[]) => void;
|
|
250
|
-
/**
|
|
251
|
-
* jade console.error
|
|
252
|
-
*/
|
|
253
|
-
declare const jError: (...args: any[]) => void;
|
|
254
|
-
/**
|
|
255
|
-
* jade console.info
|
|
256
|
-
* @param {...any} args
|
|
257
|
-
*/
|
|
258
|
-
declare const jInfo: (...args: any[]) => void;
|
|
259
|
-
/**
|
|
260
|
-
* jade console.group
|
|
261
|
-
*/
|
|
262
|
-
declare const jGroup: (...args: any[]) => void;
|
|
263
|
-
/**
|
|
264
|
-
* jade console.groupCollapsed
|
|
265
|
-
*/
|
|
266
|
-
declare const jGroupC: (...args: any[]) => void;
|
|
267
|
-
/**
|
|
268
|
-
* jade console.groupEnd
|
|
269
|
-
*/
|
|
270
|
-
declare const jGroupE: {
|
|
271
|
-
(): void;
|
|
272
|
-
(): void;
|
|
273
|
-
};
|
|
274
|
-
/**
|
|
275
|
-
* jade console.time
|
|
276
|
-
* @param str
|
|
277
|
-
*/
|
|
278
|
-
declare const jTime: (str: string) => void;
|
|
279
|
-
/**
|
|
280
|
-
* jade console.timeEnd
|
|
281
|
-
* @param str
|
|
282
|
-
*/
|
|
283
|
-
declare const jTimeEnd: (str: string) => void;
|
|
284
|
-
/**
|
|
285
|
-
* jade console.clear
|
|
286
|
-
*/
|
|
287
|
-
declare const jClear: {
|
|
288
|
-
(): void;
|
|
289
|
-
(): void;
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* 不连续打印相同的值
|
|
294
|
-
* @param args
|
|
295
|
-
*/
|
|
296
|
-
declare const jLogDedupe: (...args: any[]) => void;
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* 只打印一次
|
|
300
|
-
* @param args
|
|
301
|
-
*/
|
|
302
|
-
declare const jLogOnce: (...args: any[]) => void;
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* 隐藏中间部分
|
|
306
|
-
* @param {string} str 需要隐藏的字符串
|
|
307
|
-
* @returns {string} 隐藏后的字符串
|
|
308
|
-
* @example
|
|
309
|
-
* ```ts
|
|
310
|
-
* hideMiddle('A') // '*'
|
|
311
|
-
* hideMiddle('AB') // '**'
|
|
312
|
-
* hideMiddle('ABC') // 'A*C'
|
|
313
|
-
* hideMiddle('ABCD') // 'A**D'
|
|
314
|
-
* hideMiddle('ABCDE') // 'A***E'
|
|
315
|
-
* ```
|
|
316
|
-
*/
|
|
317
|
-
declare const hideMiddle: (str: UnDef<string>) => string;
|
|
318
|
-
/**
|
|
319
|
-
* 隐藏首尾仅保留中间3分之1
|
|
320
|
-
* @param {string} str 需要隐藏的字符串
|
|
321
|
-
* @returns {string} 隐藏后的字符串
|
|
322
|
-
* @example
|
|
323
|
-
* ```ts
|
|
324
|
-
* hideThird('A') // '*'
|
|
325
|
-
* hideThird('AB') // '**'
|
|
326
|
-
* hideThird('ABC') // 'A*C'
|
|
327
|
-
* hideThird('ABCD') // 'A**D'
|
|
328
|
-
* hideThird('ABCDE') // 'AB*DE'
|
|
329
|
-
* ```
|
|
330
|
-
*/
|
|
331
|
-
declare const hideThird: (str: UnDef<string>) => string;
|
|
332
|
-
/**
|
|
333
|
-
* 隐藏首部
|
|
334
|
-
* @param {string} str 需要隐藏的字符串
|
|
335
|
-
* @param {number} count 隐藏的字符数
|
|
336
|
-
* @returns {string} 隐藏后的字符串
|
|
337
|
-
* @example
|
|
338
|
-
* ```ts
|
|
339
|
-
* hideHead('A') // '*'
|
|
340
|
-
* hideHead('AB') // '*B'
|
|
341
|
-
* hideHead('ABC') // '**C'
|
|
342
|
-
* hideHead('ABC', 1) // '*BC'
|
|
343
|
-
* ```
|
|
344
|
-
*/
|
|
345
|
-
declare const hideHead: (str: UnDef<string>, count?: number) => string;
|
|
346
|
-
/**
|
|
347
|
-
* 隐藏尾部
|
|
348
|
-
* @param {string} str 需要隐藏的字符串
|
|
349
|
-
* @param {number} count 隐藏的字符数
|
|
350
|
-
* @returns {string} 隐藏后的字符串
|
|
351
|
-
* @example
|
|
352
|
-
* ```ts
|
|
353
|
-
* hideTail('A') // '*'
|
|
354
|
-
* hideTail('AB') // 'A*'
|
|
355
|
-
* hideTail('ABC') // 'A**'
|
|
356
|
-
* hideTail('ABC', 1) // 'AB*'
|
|
357
|
-
* ```
|
|
358
|
-
*/
|
|
359
|
-
declare const hideTail: (str: UnDef<string>, count?: number) => string;
|
|
360
|
-
/**
|
|
361
|
-
* 隐藏手机号/座机号
|
|
362
|
-
* @param {string} phone 手机号/座机号
|
|
363
|
-
* @returns {string} 隐藏后的手机号/座机号
|
|
364
|
-
* @example
|
|
365
|
-
* ```ts
|
|
366
|
-
* hidePhone('13800138000') // '138****8000'
|
|
367
|
-
* hidePhone('010-12345678') // '010****5678'
|
|
368
|
-
* hidePhone('(010)12345678') // '(010)****5678'
|
|
369
|
-
* ```
|
|
370
|
-
*/
|
|
371
|
-
declare const hidePhone: (phone: UnDef<string>) => string;
|
|
372
|
-
/**
|
|
373
|
-
* 隐藏身份证号
|
|
374
|
-
* @param {string} cardNo 身份证号
|
|
375
|
-
* @param {boolean} strong 是否强化隐藏
|
|
376
|
-
* @returns {string} 隐藏后的身份证号
|
|
377
|
-
* @example
|
|
378
|
-
* ```ts
|
|
379
|
-
* hideCardNo('33072319641008384x') // '3****************x'
|
|
380
|
-
* hideCardNo('33072319641008384x', false) // '3***23196410*****x'
|
|
381
|
-
* ```
|
|
382
|
-
*/
|
|
383
|
-
declare const hideCardNo: (cardNo: UnDef<string>, strong?: boolean) => string;
|
|
384
|
-
/**
|
|
385
|
-
* 隐藏姓氏
|
|
386
|
-
* @param {string} name 姓名
|
|
387
|
-
* @returns {string} 隐藏后的姓名
|
|
388
|
-
* @example
|
|
389
|
-
* ```ts
|
|
390
|
-
* hideSurname('张三') // '*三'
|
|
391
|
-
* hideSurname('司马懿') // '*马懿'
|
|
392
|
-
* ```
|
|
393
|
-
*/
|
|
394
|
-
declare const hideSurname: (name: UnDef<string>) => string;
|
|
395
|
-
/**
|
|
396
|
-
* 隐藏名字
|
|
397
|
-
* @param {string} name 姓名
|
|
398
|
-
* @returns {string} 隐藏后的姓名
|
|
399
|
-
* @example
|
|
400
|
-
* ```ts
|
|
401
|
-
* hideFirstName('张三') // '张*'
|
|
402
|
-
* hideFirstName('司马懿') // '司马*'
|
|
403
|
-
* ```
|
|
404
|
-
*/
|
|
405
|
-
declare const hideFirstName: (name: UnDef<string>) => string;
|
|
406
|
-
/**
|
|
407
|
-
* 隐藏邮箱
|
|
408
|
-
* @param {string} email 邮箱
|
|
409
|
-
* @returns {string} 隐藏后的邮箱
|
|
410
|
-
* @example
|
|
411
|
-
* ```ts
|
|
412
|
-
* hideEmail('example@hotmail.com') // 'exam***@hotmail.com'
|
|
413
|
-
* ```
|
|
414
|
-
*/
|
|
415
|
-
declare const hideEmail: (email: UnDef<string>) => string;
|
|
416
|
-
/**
|
|
417
|
-
* 隐藏银行卡号
|
|
418
|
-
* @param {string} bankCard 银行卡号
|
|
419
|
-
* @returns {string} 隐藏后的银行卡号
|
|
420
|
-
* @example
|
|
421
|
-
* ```ts
|
|
422
|
-
* hideBankCard('6222021001123456789') // '622202********6789'
|
|
423
|
-
* ```
|
|
424
|
-
*/
|
|
425
|
-
declare const hideBankCard: (bankCard: UnDef<string>) => string;
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* 判断是否是浏览器环境
|
|
429
|
-
*/
|
|
430
|
-
declare const inBrowser: boolean;
|
|
431
|
-
/**
|
|
432
|
-
* 等待一段时间
|
|
433
|
-
* @param time
|
|
434
|
-
*/
|
|
435
|
-
declare const waitTime: (time?: number) => Promise<unknown>;
|
|
436
|
-
/**
|
|
437
|
-
* 防止 iOS 因输入框字体小于16px 而在 focus 时页面缩放变大需要手动回正的情况。
|
|
438
|
-
* iOS 10+ 允许 pinch-zoom, 即使 viewport 是不可伸缩的。
|
|
439
|
-
* 只对这些浏览器添加额外规则
|
|
440
|
-
*/
|
|
441
|
-
declare const fixiOSInputAutoZoomIn: () => void;
|
|
442
|
-
/**
|
|
443
|
-
* 用户代理
|
|
444
|
-
*/
|
|
445
|
-
declare const userAgent: string;
|
|
446
|
-
/**
|
|
447
|
-
* 获取宿主环境信息
|
|
448
|
-
* @returns {HostEnv} 宿主环境信息
|
|
449
|
-
* @example
|
|
450
|
-
* const hostEnv = getHostEnv()
|
|
451
|
-
* hostEnv.zlb // 浙里办
|
|
452
|
-
* hostEnv.zyd // 专有钉
|
|
453
|
-
* hostEnv.zzd // 浙政钉
|
|
454
|
-
* hostEnv.dd // 钉钉/专有钉/浙政钉
|
|
455
|
-
* hostEnv.wx // 微信
|
|
456
|
-
* hostEnv.zfb // 支付宝
|
|
457
|
-
* hostEnv.mini // 小程序
|
|
458
|
-
*/
|
|
459
|
-
declare const getHostEnv: () => HostEnv;
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* 获取当小时的时间戳的异或值的绝对值, 当小时内获取的值是唯一的
|
|
463
|
-
*/
|
|
464
|
-
declare const getCodeOfHour: () => number;
|
|
465
|
-
/**
|
|
466
|
-
* 获取当天的时间戳的异或值的绝对值, 当天内获取的值是唯一的
|
|
467
|
-
*/
|
|
468
|
-
declare const getCodeOfDate: () => number;
|
|
469
|
-
/**
|
|
470
|
-
* 获取当月的时间戳的异或值的绝对值, 当月内获取的值是唯一的
|
|
471
|
-
*/
|
|
472
|
-
declare const getCodeOfMonth: () => number;
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* 设置文件基本路径
|
|
476
|
-
* @param baseUrl
|
|
477
|
-
*/
|
|
478
|
-
declare function setBaseAttachUrl(baseUrl: string): void;
|
|
479
|
-
/**
|
|
480
|
-
* 获取文件基本路径
|
|
481
|
-
*/
|
|
482
|
-
declare function getBaseAttachUrl(): string;
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* JSON 字符串转对象
|
|
486
|
-
* @template T - 解析数据类型
|
|
487
|
-
* @param {string} str - JSON字符串
|
|
488
|
-
* @param {(this: any, key: string, value: any) => any} reviverFn - 解析函数
|
|
489
|
-
* @returns {Nullable<T>} 解析后的对象
|
|
490
|
-
* @deprecated 请使用 `parseJSON`
|
|
491
|
-
*/
|
|
492
|
-
declare function parseToJSON<T = any>(str: string, reviverFn?: (this: any, key: string, value: any) => any): Nullable<T>;
|
|
493
|
-
/**
|
|
494
|
-
* JSON 字符串转对象
|
|
495
|
-
* @alias parseToJSON
|
|
496
|
-
* @template T - 解析数据类型
|
|
497
|
-
* @param {string} str - JSON字符串
|
|
498
|
-
* @param {(this: any, key: string, value: any) => any} reviverFn - 解析函数
|
|
499
|
-
* @returns {Nullable<T>} 解析后的对象
|
|
500
|
-
*/
|
|
501
|
-
declare function parseJSON<T = any>(str: string, reviverFn?: (this: any, key: string, value: any) => any): Nullable<T>;
|
|
502
|
-
/**
|
|
503
|
-
* 对象转 JSON 字符串
|
|
504
|
-
* @param {any} value - 对象
|
|
505
|
-
* @param {(this: any, key: string, value: any) => any} replacerFn - 替换函数
|
|
506
|
-
* @returns {string} JSON 字符串
|
|
507
|
-
*/
|
|
508
|
-
declare function stringifyJSON(value: any, replacerFn?: (this: any, key: string, value: any) => any): string;
|
|
509
|
-
/**
|
|
510
|
-
* JSON.stringify() second param
|
|
511
|
-
* @param _key
|
|
512
|
-
* @param value
|
|
513
|
-
*/
|
|
514
|
-
declare function replacer(_key: any, value: any): any;
|
|
515
|
-
/**
|
|
516
|
-
* JSON.parse() second param
|
|
517
|
-
* @param _key
|
|
518
|
-
* @param value
|
|
519
|
-
*/
|
|
520
|
-
declare function reviver(_key: any, value: any): any;
|
|
521
|
-
/**
|
|
522
|
-
* 过滤obj中仅包括keys的部分
|
|
523
|
-
* @param {Record<string,any>} obj 对象
|
|
524
|
-
* @param {string[]} keys 属性
|
|
525
|
-
* @param {boolean} reverse 为true时过滤取反
|
|
526
|
-
*/
|
|
527
|
-
declare const filterObj: (obj: Record<string, any>, keys: string[], reverse?: boolean) => {
|
|
528
|
-
[k: string]: any;
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* 千位分隔符
|
|
533
|
-
* @param num
|
|
534
|
-
*/
|
|
535
|
-
declare const toThousands: (num: number) => string | undefined;
|
|
536
|
-
/**
|
|
537
|
-
* 货币格式化
|
|
538
|
-
* @param {number | string | bigint} currency - 金额
|
|
539
|
-
* @param {number} [maximumFractionDigits] - 小数位数
|
|
540
|
-
*/
|
|
541
|
-
declare const currencyFmt: (currency: UnDef<Numeric | bigint>, maximumFractionDigits?: number) => string;
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* 格式化时间
|
|
545
|
-
* @param {import('dayjs').ConfigType} date 时间
|
|
546
|
-
* @param {string} format 格式
|
|
547
|
-
* @returns {string} 格式化后的时间
|
|
548
|
-
*/
|
|
549
|
-
declare const dateFmt: (date: ConfigType, format?: string | "date" | "datetime") => string;
|
|
550
|
-
/**
|
|
551
|
-
* 格式化时间间隔
|
|
552
|
-
* @param {import('dayjs').ConfigType} start 开始时间
|
|
553
|
-
* @param {import('dayjs').ConfigType} end 结束时间
|
|
554
|
-
*/
|
|
555
|
-
declare const dateDuration: (start: ConfigType, end: ConfigType) => string;
|
|
556
|
-
|
|
557
|
-
type VantUploadFileStatus = '' | 'uploading' | 'done' | 'failed'
|
|
558
|
-
type AntdUploadFileStatus = 'removed' | 'uploading' | 'done' | 'error'
|
|
559
|
-
type ElementPlusUploadFileStatus = 'ready' | 'uploading' | 'success' | 'fail'
|
|
560
|
-
|
|
561
|
-
interface Resource {
|
|
562
|
-
/** origin */
|
|
563
|
-
group: string
|
|
564
|
-
id: string
|
|
565
|
-
name: string
|
|
566
|
-
uri: string
|
|
567
|
-
/** extend */
|
|
568
|
-
url?: string
|
|
569
|
-
size?: number
|
|
570
|
-
uid?: string
|
|
571
|
-
status?: VantUploadFileStatus | AntdUploadFileStatus | ElementPlusUploadFileStatus
|
|
572
|
-
/** vant */
|
|
573
|
-
objectUrl?: string
|
|
574
|
-
content?: string
|
|
575
|
-
isImage?: boolean
|
|
576
|
-
message?: string
|
|
577
|
-
deletable?: boolean
|
|
578
|
-
reupload?: boolean
|
|
579
|
-
/** antd */
|
|
580
|
-
fileName?: string
|
|
581
|
-
percent?: number
|
|
582
|
-
thumbUrl?: string
|
|
583
|
-
/** element-plus */
|
|
584
|
-
percentage?: number
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* 获取文件完整地址
|
|
589
|
-
* @param url
|
|
590
|
-
*/
|
|
591
|
-
declare const resUrl: (url: Undefinable<string>) => string | undefined;
|
|
592
|
-
/**
|
|
593
|
-
* 统一文件字段内容
|
|
594
|
-
* @param resource
|
|
595
|
-
*/
|
|
596
|
-
declare const recoverFile: (resource: Resource) => {
|
|
597
|
-
url: string | undefined;
|
|
598
|
-
content: string | undefined;
|
|
599
|
-
uri: string;
|
|
600
|
-
status: string;
|
|
601
|
-
percent: number;
|
|
602
|
-
group: string;
|
|
603
|
-
id: string;
|
|
604
|
-
name: string;
|
|
605
|
-
size?: number;
|
|
606
|
-
uid?: string;
|
|
607
|
-
objectUrl?: string;
|
|
608
|
-
isImage?: boolean;
|
|
609
|
-
message?: string;
|
|
610
|
-
deletable?: boolean;
|
|
611
|
-
reupload?: boolean;
|
|
612
|
-
fileName?: string;
|
|
613
|
-
thumbUrl?: string;
|
|
614
|
-
percentage?: number;
|
|
615
|
-
};
|
|
616
|
-
/**
|
|
617
|
-
* 附件格式
|
|
618
|
-
* @param data
|
|
619
|
-
*/
|
|
620
|
-
declare const attachFmt: (data: UnDef<MaybeArray<Resource>> | string) => {
|
|
621
|
-
url: string | undefined;
|
|
622
|
-
content: string | undefined;
|
|
623
|
-
uri: string;
|
|
624
|
-
status: string;
|
|
625
|
-
percent: number;
|
|
626
|
-
group: string;
|
|
627
|
-
id: string;
|
|
628
|
-
name: string;
|
|
629
|
-
size?: number;
|
|
630
|
-
uid?: string;
|
|
631
|
-
objectUrl?: string;
|
|
632
|
-
isImage?: boolean;
|
|
633
|
-
message?: string;
|
|
634
|
-
deletable?: boolean;
|
|
635
|
-
reupload?: boolean;
|
|
636
|
-
fileName?: string;
|
|
637
|
-
thumbUrl?: string;
|
|
638
|
-
percentage?: number;
|
|
639
|
-
}[];
|
|
640
|
-
|
|
641
|
-
/**
|
|
642
|
-
* 自然排序
|
|
643
|
-
* @param {UnDef<string>[] | UnDef<number>[]} arr - 数字或字符串数组
|
|
644
|
-
* @returns {UnDef<string>[] | UnDef<number>[]} - 排序后的数组
|
|
645
|
-
*/
|
|
646
|
-
declare const naturalSort: (arr: UnDef<string>[] | UnDef<number>[]) => UnDef<string>[] | UnDef<number>[];
|
|
647
|
-
/**
|
|
648
|
-
* 根据 key 自然排序
|
|
649
|
-
* @param arr - 数组
|
|
650
|
-
* @param {string} key - 键名
|
|
651
|
-
* @returns {any[]} - 排序后的数组
|
|
652
|
-
*/
|
|
653
|
-
declare const naturalSortBy: <T extends Record<string, UnDef<Numeric>>>(arr: T[], key: keyof T) => T[];
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* 检测变量类型
|
|
657
|
-
* @param {any} val 检测的目标
|
|
658
|
-
*/
|
|
659
|
-
declare const getVariableType: (val: any) => string | undefined;
|
|
660
|
-
/**
|
|
661
|
-
* 是否是数字
|
|
662
|
-
* @param {any} val 检测的目标
|
|
663
|
-
*/
|
|
664
|
-
declare const isNumber: (val: any) => val is number;
|
|
665
|
-
/**
|
|
666
|
-
* 是否是任意精度整数
|
|
667
|
-
* @param {any} val 检测的目标
|
|
668
|
-
*/
|
|
669
|
-
declare const isBigInt: (val: any) => val is bigint;
|
|
670
|
-
/**
|
|
671
|
-
* 是否是字符串
|
|
672
|
-
* @param {any} val 检测的目标
|
|
673
|
-
*/
|
|
674
|
-
declare const isString: (val: any) => val is string;
|
|
675
|
-
/**
|
|
676
|
-
* 是否是布尔值
|
|
677
|
-
* @param {any} val 检测的目标
|
|
678
|
-
*/
|
|
679
|
-
declare const isBoolean: (val: any) => val is boolean;
|
|
680
|
-
/**
|
|
681
|
-
* 是否是null
|
|
682
|
-
* @param {any} val 检测的目标
|
|
683
|
-
*/
|
|
684
|
-
declare const isNull: (val: any) => val is null;
|
|
685
|
-
/**
|
|
686
|
-
* 是否是undefined
|
|
687
|
-
* @param {any} val 检测的目标
|
|
688
|
-
*/
|
|
689
|
-
declare const isUndefined: (val: any) => val is undefined;
|
|
690
|
-
/**
|
|
691
|
-
* 是否是symbol
|
|
692
|
-
* @param {any} val 检测的目标
|
|
693
|
-
*/
|
|
694
|
-
declare const isSymbol: (val: any) => val is symbol;
|
|
695
|
-
/**
|
|
696
|
-
* 是否是对象
|
|
697
|
-
* @param {any} val 检测的目标
|
|
698
|
-
*/
|
|
699
|
-
declare const isObject: (val: any) => val is Record<any, any>;
|
|
700
|
-
/**
|
|
701
|
-
* 是否是数组
|
|
702
|
-
* @param {any} val 检测的目标
|
|
703
|
-
*/
|
|
704
|
-
declare const isArray: (val: any) => val is Array<any>;
|
|
705
|
-
/**
|
|
706
|
-
* 是否是函数,但也有可能是Class
|
|
707
|
-
* @param {any} val 检测的目标
|
|
708
|
-
*/
|
|
709
|
-
declare const isFunction: (val: any) => val is Function;
|
|
710
|
-
/**
|
|
711
|
-
* 是否是日期
|
|
712
|
-
* @param {any} val 检测的目标
|
|
713
|
-
*/
|
|
714
|
-
declare const isDate: (val: any) => val is Date;
|
|
715
|
-
/**
|
|
716
|
-
* 是否是正则
|
|
717
|
-
* @param {any} val 检测的目标
|
|
718
|
-
*/
|
|
719
|
-
declare const isRegExp: (val: any) => val is RegExp;
|
|
720
|
-
/**
|
|
721
|
-
* 是否是期望(Promise)
|
|
722
|
-
* @param {any} val 检测的目标
|
|
723
|
-
*/
|
|
724
|
-
declare const isPromise: (val: any) => val is Promise<any>;
|
|
725
|
-
/**
|
|
726
|
-
* 是否是集合(Set)
|
|
727
|
-
* @param {any} val 检测的目标
|
|
728
|
-
*/
|
|
729
|
-
declare const isSet: (val: any) => val is Set<any>;
|
|
730
|
-
/**
|
|
731
|
-
* 是否是映射(Map)
|
|
732
|
-
* @param {any} val 检测的目标
|
|
733
|
-
*/
|
|
734
|
-
declare const isMap: (val: any) => val is Map<any, any>;
|
|
735
|
-
/**
|
|
736
|
-
* 是否是弱集合(WeakSet)
|
|
737
|
-
* @param {any} val 检测的目标
|
|
738
|
-
*/
|
|
739
|
-
declare const isWeakSet: (val: any) => val is WeakSet<any>;
|
|
740
|
-
/**
|
|
741
|
-
* 是否是弱映射(WeakMap)
|
|
742
|
-
* @param {any} val 检测的目标
|
|
743
|
-
*/
|
|
744
|
-
declare const isWeakMap: (val: any) => val is WeakMap<any, any>;
|
|
745
|
-
/**
|
|
746
|
-
* 是否是File
|
|
747
|
-
* @param {any} val 检测的目标
|
|
748
|
-
*/
|
|
749
|
-
declare const isFile: (val: any) => val is File;
|
|
750
|
-
/**
|
|
751
|
-
* 是否是Blob
|
|
752
|
-
* @param {any} val 检测的目标
|
|
753
|
-
*/
|
|
754
|
-
declare const isBlob: (val: any) => val is Blob;
|
|
755
|
-
/**
|
|
756
|
-
* 是否是URL
|
|
757
|
-
* @param {any} val 检测的目标
|
|
758
|
-
*/
|
|
759
|
-
declare const isURL: (val: any) => val is URL;
|
|
760
|
-
/**
|
|
761
|
-
* 是否是错误(Error)
|
|
762
|
-
* @param {any} val 检测的目标
|
|
763
|
-
*/
|
|
764
|
-
declare const isError: (val: any) => val is Error;
|
|
765
|
-
/**
|
|
766
|
-
* 是否既不是 null 也不是 undefined
|
|
767
|
-
* @param {any} val 检测的目标
|
|
768
|
-
*/
|
|
769
|
-
declare const isDef: <T>(val: T) => val is NonNullable<T>;
|
|
770
|
-
/**
|
|
771
|
-
* 判断是否合法JSON字符串
|
|
772
|
-
* @param str
|
|
773
|
-
*/
|
|
774
|
-
declare const isJSONStr: (str: UnDef<string>) => boolean;
|
|
775
|
-
/**
|
|
776
|
-
* 判断是否合法JSON数组字符串
|
|
777
|
-
* @param str
|
|
778
|
-
*/
|
|
779
|
-
declare const isArrStr: (str: UnDef<string>) => boolean;
|
|
780
|
-
/**
|
|
781
|
-
* 判断是否有效的key
|
|
782
|
-
* @param {string | number | symbol} key 键名
|
|
783
|
-
* @param {object} object 对象
|
|
784
|
-
* @example
|
|
785
|
-
*
|
|
786
|
-
* ```ts
|
|
787
|
-
* const obj = { a: 1, b: 2 }
|
|
788
|
-
* isValidKey('a', obj) // true
|
|
789
|
-
* ```
|
|
790
|
-
* @returns {boolean} boolean
|
|
791
|
-
*/
|
|
792
|
-
declare const isValidKey: (key: string | number | symbol, object: object) => key is keyof typeof object;
|
|
793
|
-
/**
|
|
794
|
-
* 是否是空值/空数组/空对象 null undefined '' [] {} Set Map
|
|
795
|
-
* @param val
|
|
796
|
-
*/
|
|
797
|
-
declare const isEmpty: (val: UnDef<Numeric | boolean | Record<any, any> | Array<any> | Set<any> | Map<any, any>>) => boolean;
|
|
798
|
-
|
|
799
|
-
declare const cnPhoneRE: RegExp;
|
|
800
|
-
declare const cnTelRE: RegExp;
|
|
801
|
-
declare const cnTelRE2: RegExp;
|
|
802
|
-
declare const cnUSCIRE: RegExp;
|
|
803
|
-
declare const cnIdCard15Re: RegExp;
|
|
804
|
-
declare const cnIdCard18Re: RegExp;
|
|
805
|
-
declare const emailRE: RegExp;
|
|
806
|
-
/**
|
|
807
|
-
* 是否是[统一社会信用代码](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)
|
|
808
|
-
* @example
|
|
809
|
-
* ```ts
|
|
810
|
-
* isUSCI('91350100M000100Y43') // true
|
|
811
|
-
* ```
|
|
812
|
-
* @param {UnDef<string>} val - 待校验的值
|
|
813
|
-
* @returns {boolean} 是否是统一社会信用代码
|
|
814
|
-
*/
|
|
815
|
-
declare const isUSCI: (val: UnDef<string>) => boolean;
|
|
816
|
-
/**
|
|
817
|
-
* 是否是中国手机号
|
|
818
|
-
* @param val
|
|
819
|
-
*/
|
|
820
|
-
declare const isPhone: (val: UnDef<Numeric>) => boolean;
|
|
821
|
-
/**
|
|
822
|
-
* 是否是中国座机号
|
|
823
|
-
* @param val
|
|
824
|
-
*/
|
|
825
|
-
declare const isTel: (val: UnDef<Numeric>) => boolean;
|
|
826
|
-
/**
|
|
827
|
-
* 是否是邮箱
|
|
828
|
-
* @param val
|
|
829
|
-
*/
|
|
830
|
-
declare const isEmail: (val: UnDef<string>) => boolean;
|
|
831
|
-
/**
|
|
832
|
-
* 是否是身份证
|
|
833
|
-
* @param {string|null|undefined} val 身份证号
|
|
834
|
-
* @param {boolean} compatible 兼容15位
|
|
835
|
-
*/
|
|
836
|
-
declare const isIdCard: (val: UnDef<string>, compatible?: boolean) => boolean;
|
|
837
|
-
/**
|
|
838
|
-
* 是否是数字或字符
|
|
839
|
-
* @param val
|
|
840
|
-
*/
|
|
841
|
-
declare const isNumeric: (val: UnDef<Numeric>) => val is string;
|
|
842
|
-
/**
|
|
843
|
-
* 是否是需要的图片格式
|
|
844
|
-
* @param ext
|
|
845
|
-
*/
|
|
846
|
-
declare const checkImg: (ext?: string) => boolean;
|
|
847
|
-
/**
|
|
848
|
-
* 包含非ASCII字符
|
|
849
|
-
* @param text
|
|
850
|
-
*/
|
|
851
|
-
declare const nonASCII: (text: string) => boolean;
|
|
852
|
-
/**
|
|
853
|
-
* 校验文件类型
|
|
854
|
-
* 1. XXX/YYY 2. .xxx 3. XXX/* 4.*
|
|
855
|
-
* @param {File} file 需要校验的文件
|
|
856
|
-
* @param {string} type 文件类型, 与input.accept一致
|
|
857
|
-
*/
|
|
858
|
-
declare const isValidFileType: (file: File, type: string) => boolean;
|
|
859
|
-
|
|
860
|
-
/**
|
|
861
|
-
* 校验接口返回code
|
|
862
|
-
* @param res
|
|
863
|
-
* @param code
|
|
864
|
-
*/
|
|
865
|
-
declare const isValidResCode: (res: Res, code?: number) => boolean;
|
|
866
|
-
/**
|
|
867
|
-
* 校验接口返回内容
|
|
868
|
-
* @param res
|
|
869
|
-
* @param code
|
|
870
|
-
*/
|
|
871
|
-
declare const isValidRes: (res: Res, code?: number) => boolean;
|
|
872
|
-
/**
|
|
873
|
-
* 校验接口数组返回内容
|
|
874
|
-
* @param res
|
|
875
|
-
* @param code
|
|
876
|
-
*/
|
|
877
|
-
declare const isValidArrRes: (res: Res<any[]>, code?: number) => boolean;
|
|
878
|
-
/**
|
|
879
|
-
* 校验接口分页返回内容
|
|
880
|
-
* @param res
|
|
881
|
-
* @param code
|
|
882
|
-
*/
|
|
883
|
-
declare const isValidPageRes: (res: PageRes, code?: number) => boolean;
|
|
884
|
-
|
|
885
|
-
export { attachFmt, camel2Kebab, camel2Pascal, camel2Snake, camel2Title, checkImg, cnIdCard15Re, cnIdCard18Re, cnPhoneRE, cnTelRE, cnTelRE2, cnUSCIRE, currencyFmt, dateDuration, dateFmt, emailRE, filterObj, fixiOSInputAutoZoomIn, getBaseAttachUrl, getCodeOfDate, getCodeOfHour, getCodeOfMonth, getHostEnv, 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, 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 };
|
|
886
|
-
export type { Dict, HostEnv, MaybeArray, NullOrUndefinable, Nullable, Numeric, PageReq, PageRes, PageResData, PartialBy, Res, UnDef, Undefinable, VK };
|