@pawover/kit 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +42 -45
- package/packages/hooks/dist/alova.d.ts +3 -4
- package/packages/hooks/dist/metadata.json +0 -1
- package/packages/hooks/dist/react.d.ts +4 -13
- package/packages/hooks/dist/react.js +820 -244
- package/packages/utils/dist/index.d.ts +697 -70
- package/packages/utils/dist/index.js +216 -2
- package/packages/utils/dist/math.d.ts +4 -0
- package/packages/utils/dist/math.js +1 -1
- package/packages/utils/dist/{string-DCWqoW4P.js → string-p6hZ1Mjb.js} +174 -7
- package/packages/utils/dist/vite.d.ts +13 -0
- package/packages/utils/dist/vite.js +13 -0
|
@@ -13,15 +13,20 @@ declare class ArrayUtil {
|
|
|
13
13
|
* @returns 构造后的数组
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
16
|
+
* // 重载 1: checkEmpty = true (默认)
|
|
16
17
|
* ArrayUtil.cast(1); // [1]
|
|
17
|
-
* ArrayUtil.cast([1, 2]); // [1, 2]
|
|
18
18
|
* ArrayUtil.cast(null); // []
|
|
19
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* // 重载 2: checkEmpty = false
|
|
20
21
|
* ArrayUtil.cast(null, false); // [null]
|
|
22
|
+
*
|
|
23
|
+
* // 通用场景
|
|
24
|
+
* ArrayUtil.cast([1, 2]); // [1, 2]
|
|
25
|
+
* ArrayUtil.cast(undefined); // []
|
|
21
26
|
* ```
|
|
22
27
|
*/
|
|
23
28
|
static cast<T>(candidate: T | T[] | null | undefined, checkEmpty?: true): NonNullable<T>[];
|
|
24
|
-
static cast<T>(candidate: T | T[] | null | undefined, checkEmpty
|
|
29
|
+
static cast<T>(candidate: T | T[] | null | undefined, checkEmpty: false): T[];
|
|
25
30
|
/**
|
|
26
31
|
* 获取数组第一项
|
|
27
32
|
*
|
|
@@ -30,7 +35,11 @@ declare class ArrayUtil {
|
|
|
30
35
|
* @returns 数组第一项,如果为空则返回回退值
|
|
31
36
|
* @example
|
|
32
37
|
* ```ts
|
|
38
|
+
* // 重载 1: 无 fallback
|
|
33
39
|
* ArrayUtil.first([1, 2]); // 1
|
|
40
|
+
* ArrayUtil.first([]); // undefined
|
|
41
|
+
*
|
|
42
|
+
* // 重载 2: 有 fallback
|
|
34
43
|
* ArrayUtil.first([], 0); // 0
|
|
35
44
|
* ```
|
|
36
45
|
*/
|
|
@@ -44,7 +53,11 @@ declare class ArrayUtil {
|
|
|
44
53
|
* @returns 数组最后一项,如果为空则返回回退值
|
|
45
54
|
* @example
|
|
46
55
|
* ```ts
|
|
56
|
+
* // 重载 1: 无 fallback
|
|
47
57
|
* ArrayUtil.last([1, 2, 3]); // 3
|
|
58
|
+
* ArrayUtil.last([]); // undefined
|
|
59
|
+
*
|
|
60
|
+
* // 重载 2: 有 fallback
|
|
48
61
|
* ArrayUtil.last([], 0); // 0
|
|
49
62
|
* ```
|
|
50
63
|
*/
|
|
@@ -107,7 +120,10 @@ declare class ArrayUtil {
|
|
|
107
120
|
* @returns 交集数组
|
|
108
121
|
* @example
|
|
109
122
|
* ```ts
|
|
123
|
+
* // 重载 1: 按元素本身比较
|
|
110
124
|
* ArrayUtil.intersection([1, 2], [2, 3]); // [2]
|
|
125
|
+
*
|
|
126
|
+
* // 重载 2: 按 match 结果比较
|
|
111
127
|
* ArrayUtil.intersection([{ id: 1 }, { id: 2 }], [{ id: 2 }], (x) => x.id); // [{ id: 2 }]
|
|
112
128
|
* ```
|
|
113
129
|
*/
|
|
@@ -124,11 +140,11 @@ declare class ArrayUtil {
|
|
|
124
140
|
* @returns 合并后的数组
|
|
125
141
|
* @example
|
|
126
142
|
* ```ts
|
|
127
|
-
* // 基础合并去重
|
|
143
|
+
* // 重载 1: 基础合并去重
|
|
128
144
|
* ArrayUtil.merge([1, 2], [2, 3]); // [1, 2, 3]
|
|
129
145
|
* ArrayUtil.merge([], [1, 2, 3]); // [1, 2, 3]
|
|
130
146
|
*
|
|
131
|
-
* // 按条件更新
|
|
147
|
+
* // 重载 2: 按条件更新
|
|
132
148
|
* const source = [{ id: 1, val: "a" }, { id: 2, val: "b" }];
|
|
133
149
|
* const update = [{ id: 2, val: "new" }, { id: 3, val: "c" }];
|
|
134
150
|
* ArrayUtil.merge(source, update, (x) => x.id); // [{ id: 1, val: "a" }, { id: 2, val: "new" }] -> id:3 被忽略
|
|
@@ -147,7 +163,11 @@ declare class ArrayUtil {
|
|
|
147
163
|
* @example
|
|
148
164
|
* ```ts
|
|
149
165
|
* const list = [1, 2, 3, 4];
|
|
166
|
+
*
|
|
167
|
+
* // 重载 1: 仅过滤
|
|
150
168
|
* ArrayUtil.pick(list, (n) => n % 2 === 0); // [2, 4]
|
|
169
|
+
*
|
|
170
|
+
* // 重载 2: 过滤 + 映射
|
|
151
171
|
* ArrayUtil.pick(list, (n) => n % 2 === 0, (n) => n * 2); // [4, 8]
|
|
152
172
|
* ```
|
|
153
173
|
*/
|
|
@@ -164,7 +184,11 @@ declare class ArrayUtil {
|
|
|
164
184
|
* @returns 替换后的新数组
|
|
165
185
|
* @example
|
|
166
186
|
* ```ts
|
|
187
|
+
* // 重载 1/2: newItem 与数组元素类型兼容
|
|
167
188
|
* ArrayUtil.replace([1, 2, 3], 4, (n) => n === 2); // [1, 4, 3]
|
|
189
|
+
*
|
|
190
|
+
* // 重载 3: newItem 可扩展为新类型
|
|
191
|
+
* ArrayUtil.replace([1, 2, 3], "X", (n) => n === 2); // [1, "X", 3]
|
|
168
192
|
* ```
|
|
169
193
|
*/
|
|
170
194
|
static replace<const T>(initialList: readonly T[], newItem: T, match: MatchFunction<T, boolean>): T[];
|
|
@@ -236,7 +260,20 @@ declare class ArrayUtil {
|
|
|
236
260
|
* @returns 压缩后的元组数组
|
|
237
261
|
* @example
|
|
238
262
|
* ```ts
|
|
263
|
+
* // 重载 1: 两个数组
|
|
239
264
|
* ArrayUtil.zip([1, 2], ["a", "b"]); // [[1, "a"], [2, "b"]]
|
|
265
|
+
*
|
|
266
|
+
* // 重载 2: 三个数组
|
|
267
|
+
* ArrayUtil.zip([1, 2], ["a", "b"], [true, false]); // [[1, "a", true], [2, "b", false]]
|
|
268
|
+
*
|
|
269
|
+
* // 重载 3: 四个数组
|
|
270
|
+
* ArrayUtil.zip([1], ["a"], [true], ["x"]); // [[1, "a", true, "x"]]
|
|
271
|
+
*
|
|
272
|
+
* // 重载 4: 五个数组
|
|
273
|
+
* ArrayUtil.zip([1], ["a"], [true], ["x"], [9]); // [[1, "a", true, "x", 9]]
|
|
274
|
+
*
|
|
275
|
+
* // 重载 5: 空参数
|
|
276
|
+
* ArrayUtil.zip(); // []
|
|
240
277
|
* ```
|
|
241
278
|
*/
|
|
242
279
|
static zip<T1, T2, T3, T4, T5>(array1: readonly T1[], array2: readonly T2[], array3: readonly T3[], array4: readonly T4[], array5: readonly T5[]): [T1, T2, T3, T4, T5][];
|
|
@@ -253,8 +290,13 @@ declare class ArrayUtil {
|
|
|
253
290
|
* @returns 生成的对象
|
|
254
291
|
* @example
|
|
255
292
|
* ```ts
|
|
293
|
+
* // 重载 1: 传值数组
|
|
256
294
|
* ArrayUtil.zipToObject(["a", "b"], [1, 2]); // { a: 1, b: 2 }
|
|
295
|
+
*
|
|
296
|
+
* // 重载 2: 传生成函数
|
|
257
297
|
* ArrayUtil.zipToObject(["a", "b"], (k, i) => k + i); // { a: "a0", b: "b1" }
|
|
298
|
+
*
|
|
299
|
+
* // 重载 3: 传静态值
|
|
258
300
|
* ArrayUtil.zipToObject(["a", "b"], 1); // { a: 1, b: 1 }
|
|
259
301
|
* ```
|
|
260
302
|
*/
|
|
@@ -270,52 +312,109 @@ declare class ArrayUtil {
|
|
|
270
312
|
declare class DateTimeUtil {
|
|
271
313
|
/**
|
|
272
314
|
* 每秒的毫秒数
|
|
315
|
+
* @example
|
|
316
|
+
* ```ts
|
|
317
|
+
* DateTimeUtil.MILLISECONDS_PER_SECOND; // 1000
|
|
318
|
+
* ```
|
|
273
319
|
*/
|
|
274
320
|
static readonly MILLISECONDS_PER_SECOND: number;
|
|
275
321
|
/**
|
|
276
322
|
* 每分钟的秒数
|
|
323
|
+
* @example
|
|
324
|
+
* ```ts
|
|
325
|
+
* DateTimeUtil.SECOND_PER_MINUTE; // 60
|
|
326
|
+
* ```
|
|
277
327
|
*/
|
|
278
328
|
static readonly SECOND_PER_MINUTE: number;
|
|
279
329
|
/**
|
|
280
330
|
* 每小时的分钟数
|
|
331
|
+
* @example
|
|
332
|
+
* ```ts
|
|
333
|
+
* DateTimeUtil.MINUTE_PER_HOUR; // 60
|
|
334
|
+
* ```
|
|
281
335
|
*/
|
|
282
336
|
static readonly MINUTE_PER_HOUR: number;
|
|
283
337
|
/**
|
|
284
338
|
* 每小时的秒数
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* DateTimeUtil.SECOND_PER_HOUR; // 3600
|
|
342
|
+
* ```
|
|
285
343
|
*/
|
|
286
344
|
static readonly SECOND_PER_HOUR: number;
|
|
287
345
|
/**
|
|
288
346
|
* 每天小时数
|
|
347
|
+
* @example
|
|
348
|
+
* ```ts
|
|
349
|
+
* DateTimeUtil.HOUR_PER_DAY; // 24
|
|
350
|
+
* ```
|
|
289
351
|
*/
|
|
290
352
|
static readonly HOUR_PER_DAY: number;
|
|
291
353
|
/**
|
|
292
354
|
* 每天秒数
|
|
355
|
+
* @example
|
|
356
|
+
* ```ts
|
|
357
|
+
* DateTimeUtil.SECOND_PER_DAY; // 86400
|
|
358
|
+
* ```
|
|
293
359
|
*/
|
|
294
360
|
static readonly SECOND_PER_DAY: number;
|
|
295
361
|
/**
|
|
296
362
|
* 每周天数
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts
|
|
365
|
+
* DateTimeUtil.DAY_PER_WEEK; // 7
|
|
366
|
+
* ```
|
|
297
367
|
*/
|
|
298
368
|
static readonly DAY_PER_WEEK: number;
|
|
299
369
|
/**
|
|
300
370
|
* 每月天数
|
|
371
|
+
* @example
|
|
372
|
+
* ```ts
|
|
373
|
+
* DateTimeUtil.DAY_PER_MONTH; // 30
|
|
374
|
+
* ```
|
|
301
375
|
*/
|
|
302
376
|
static readonly DAY_PER_MONTH: number;
|
|
303
377
|
/**
|
|
304
378
|
* 每年天数
|
|
379
|
+
* @example
|
|
380
|
+
* ```ts
|
|
381
|
+
* DateTimeUtil.DAY_PER_YEAR; // 365
|
|
382
|
+
* ```
|
|
305
383
|
*/
|
|
306
384
|
static readonly DAY_PER_YEAR: number;
|
|
307
385
|
/**
|
|
308
386
|
* 每年月数
|
|
387
|
+
* @example
|
|
388
|
+
* ```ts
|
|
389
|
+
* DateTimeUtil.MONTH_PER_YEAR; // 12
|
|
390
|
+
* ```
|
|
309
391
|
*/
|
|
310
392
|
static readonly MONTH_PER_YEAR: number;
|
|
311
393
|
/**
|
|
312
394
|
* 每年平均周
|
|
395
|
+
* @example
|
|
396
|
+
* ```ts
|
|
397
|
+
* DateTimeUtil.WEEK_PER_YEAR; // 52
|
|
398
|
+
* ```
|
|
313
399
|
*/
|
|
314
400
|
static readonly WEEK_PER_YEAR: number;
|
|
315
401
|
/**
|
|
316
402
|
* 每月平均周
|
|
403
|
+
* @example
|
|
404
|
+
* ```ts
|
|
405
|
+
* DateTimeUtil.WEEK_PER_MONTH; // 4
|
|
406
|
+
* ```
|
|
317
407
|
*/
|
|
318
408
|
static readonly WEEK_PER_MONTH: number;
|
|
409
|
+
/**
|
|
410
|
+
* 常用时间格式模板集合
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```ts
|
|
414
|
+
* DateTimeUtil.FORMAT.ISO_DATE; // "yyyy-MM-dd"
|
|
415
|
+
* DateTimeUtil.FORMAT.CN_DATE_TIME; // "yyyy年MM月dd日 HH时mm分ss秒"
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
319
418
|
static readonly FORMAT: {
|
|
320
419
|
readonly ISO_DATE: "yyyy-MM-dd";
|
|
321
420
|
readonly ISO_TIME: "HH:mm:ss";
|
|
@@ -372,11 +471,44 @@ declare class EnvUtil {
|
|
|
372
471
|
private static readonly _isBrowser;
|
|
373
472
|
private static readonly _isWebWorker;
|
|
374
473
|
private static readonly _isReactNative;
|
|
474
|
+
/**
|
|
475
|
+
* 检测是否处于浏览器环境
|
|
476
|
+
*
|
|
477
|
+
* @returns 是否为浏览器环境
|
|
478
|
+
* @example
|
|
479
|
+
* ```ts
|
|
480
|
+
* EnvUtil.isBrowser(); // true: 浏览器, false: Node.js
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
375
483
|
static isBrowser(): boolean;
|
|
484
|
+
/**
|
|
485
|
+
* 检测是否处于 Web Worker 环境
|
|
486
|
+
*
|
|
487
|
+
* @returns 是否为 Web Worker 环境
|
|
488
|
+
* @example
|
|
489
|
+
* ```ts
|
|
490
|
+
* EnvUtil.isWebWorker(); // true: Worker, false: 主线程/Node.js
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
376
493
|
static isWebWorker(): boolean;
|
|
494
|
+
/**
|
|
495
|
+
* 检测是否处于 React Native 环境
|
|
496
|
+
*
|
|
497
|
+
* @returns 是否为 React Native 环境
|
|
498
|
+
* @example
|
|
499
|
+
* ```ts
|
|
500
|
+
* EnvUtil.isReactNative(); // true: React Native, false: Web/Node.js
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
377
503
|
static isReactNative(): boolean;
|
|
378
504
|
/**
|
|
379
505
|
* 检查是否在 iframe 环境中
|
|
506
|
+
*
|
|
507
|
+
* @returns 是否在 iframe 中
|
|
508
|
+
* @example
|
|
509
|
+
* ```ts
|
|
510
|
+
* EnvUtil.isIframe(); // true: 当前页面在 iframe 中
|
|
511
|
+
* ```
|
|
380
512
|
*/
|
|
381
513
|
static isIframe(): boolean;
|
|
382
514
|
/**
|
|
@@ -466,9 +598,9 @@ declare class EnvUtil {
|
|
|
466
598
|
static isTablet(minWidth?: number, maxWidth?: number, dpi?: number): boolean;
|
|
467
599
|
}
|
|
468
600
|
//#endregion
|
|
469
|
-
//#region ../../node_modules/.pnpm/@pawover+types@0.0.
|
|
601
|
+
//#region ../../node_modules/.pnpm/@pawover+types@0.0.2_@types+react@19.2.15_typescript@6.0.3/node_modules/@pawover/types/dist/index.d.ts
|
|
470
602
|
//#endregion
|
|
471
|
-
//#region src/
|
|
603
|
+
//#region src/global.d.ts
|
|
472
604
|
/** 任意对象类型 */
|
|
473
605
|
type AnyObject<K extends PropertyKey = PropertyKey, T = any> = Record<K, T>;
|
|
474
606
|
/** 普通对象类型 */
|
|
@@ -482,7 +614,8 @@ type AnyAsyncFunction<P extends any[] = any[], R = any> = (...args: P) => Promis
|
|
|
482
614
|
/** 描述生成器函数类型 */
|
|
483
615
|
type AnyGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => Generator<T, R, N>;
|
|
484
616
|
/** 描述异步生成器函数类型 */
|
|
485
|
-
type AnyAsyncGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => AsyncGenerator<T, R, N>;
|
|
617
|
+
type AnyAsyncGeneratorFunction<P extends any[] = any[], T = any, R = any, N = any> = (...args: P) => AsyncGenerator<T, R, N>;
|
|
618
|
+
/** 描述无返回值函数 */
|
|
486
619
|
//#endregion
|
|
487
620
|
//#region src/function/functionUtil.d.ts
|
|
488
621
|
/**
|
|
@@ -514,6 +647,7 @@ declare class FunctionUtil {
|
|
|
514
647
|
* @throws TypeError 如果 args 为 null 或 undefined
|
|
515
648
|
*
|
|
516
649
|
* @example
|
|
650
|
+
* ```ts
|
|
517
651
|
* // 遗留代码场景
|
|
518
652
|
* function legacyFn(a: number, b: string) {
|
|
519
653
|
* const argsArray = FunctionUtil.toArgs(arguments);
|
|
@@ -530,6 +664,7 @@ declare class FunctionUtil {
|
|
|
530
664
|
* const rest = FunctionUtil.toArgs(arguments, 1);
|
|
531
665
|
* // rest: unknown[],跳过第一个参数
|
|
532
666
|
* }
|
|
667
|
+
* ```
|
|
533
668
|
*/
|
|
534
669
|
static toArgs<T = unknown>(args: IArguments, start?: number | undefined): T[];
|
|
535
670
|
/**
|
|
@@ -540,6 +675,7 @@ declare class FunctionUtil {
|
|
|
540
675
|
* @returns 标准化的 Promise
|
|
541
676
|
*
|
|
542
677
|
* @example
|
|
678
|
+
* ```ts
|
|
543
679
|
* // 同步函数
|
|
544
680
|
* FunctionUtil.toPromise(() => 42).then(v => console.log(v)); // 42
|
|
545
681
|
*
|
|
@@ -548,6 +684,7 @@ declare class FunctionUtil {
|
|
|
548
684
|
*
|
|
549
685
|
* // 异常处理
|
|
550
686
|
* FunctionUtil.toPromise(() => { throw new Error('fail'); }).catch(err => console.error(err)); // 捕获同步异常
|
|
687
|
+
* ```
|
|
551
688
|
*/
|
|
552
689
|
static toPromise<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
553
690
|
}
|
|
@@ -568,8 +705,23 @@ declare class MimeUtil {
|
|
|
568
705
|
readonly CSV: "text/csv"; /** 制表符分隔值文件 */
|
|
569
706
|
readonly TSV: "text/tab-separated-values"; /** XML 文档 */
|
|
570
707
|
readonly XML: "text/xml"; /** XHTML 文档(XML 严格格式的 HTML) */
|
|
571
|
-
readonly XHTML: "application/xhtml+xml"; /** JavaScript
|
|
572
|
-
readonly JS: "text/javascript"; /**
|
|
708
|
+
readonly XHTML: "application/xhtml+xml"; /** JavaScript 文件 */
|
|
709
|
+
readonly JS: "text/javascript"; /** TypeScript 文件 */
|
|
710
|
+
readonly TS: "text/typescript"; /** Python 文件 */
|
|
711
|
+
readonly PY: "text/x-python"; /** Shell 脚本 (.sh) */
|
|
712
|
+
readonly SH: "text/x-sh"; /** C 语言源文件 */
|
|
713
|
+
readonly C: "text/x-c"; /** C++ 源文件 */
|
|
714
|
+
readonly CPP: "text/x-c++"; /** C# 源文件 */
|
|
715
|
+
readonly CSHARP: "text/x-csharp"; /** Java 源文件 */
|
|
716
|
+
readonly JAVA: "text/x-java"; /** Go 源文件 */
|
|
717
|
+
readonly GO: "text/x-go"; /** Rust 源文件 */
|
|
718
|
+
readonly RUST: "text/x-rust"; /** PHP 文件 */
|
|
719
|
+
readonly PHP: "text/x-php"; /** Ruby 文件 */
|
|
720
|
+
readonly RUBY: "text/x-ruby"; /** Swift 源文件 */
|
|
721
|
+
readonly SWIFT: "text/x-swift"; /** YAML 文档 */
|
|
722
|
+
readonly YAML: "text/vnd.yaml"; /** TOML 文档 */
|
|
723
|
+
readonly TOML: "text/x-toml"; /** SQL 脚本 */
|
|
724
|
+
readonly SQL: "text/x-sql"; /** Markdown 格式文档 */
|
|
573
725
|
readonly MARKDOWN: "text/markdown"; /** 富文本格式文档(.rtf) */
|
|
574
726
|
readonly RTF: "application/rtf"; /** iCalendar 日历格式(.ics) */
|
|
575
727
|
readonly CALENDAR: "text/calendar"; /** JPEG 图像(.jpg/.jpeg) */
|
|
@@ -581,7 +733,10 @@ declare class MimeUtil {
|
|
|
581
733
|
readonly APNG: "image/apng"; /** AVIF 图像(高效压缩) */
|
|
582
734
|
readonly AVIF: "image/avif"; /** 图标文件格式(.ico) */
|
|
583
735
|
readonly ICO: "image/vnd.microsoft.icon"; /** WebP 图像(高效压缩) */
|
|
584
|
-
readonly WEBP: "image/webp"; /**
|
|
736
|
+
readonly WEBP: "image/webp"; /** TIFF 图像(.tif/.tiff) */
|
|
737
|
+
readonly TIFF: "image/tiff"; /** HEIC 图像(高效编码) */
|
|
738
|
+
readonly HEIC: "image/heic"; /** Adobe Photoshop 文件(.psd) */
|
|
739
|
+
readonly PSD: "image/vnd.adobe.photoshop"; /** MP3 音频(.mp3) */
|
|
585
740
|
readonly MP3: "audio/mpeg"; /** AAC 音频(.aac) */
|
|
586
741
|
readonly AAC: "audio/aac"; /** MIDI 音乐文件(.mid/.midi) */
|
|
587
742
|
readonly MIDI: "audio/midi"; /** OGG 音频(.oga) */
|
|
@@ -615,13 +770,18 @@ declare class MimeUtil {
|
|
|
615
770
|
readonly TAR: "application/x-tar"; /** BZip 归档(.bz) */
|
|
616
771
|
readonly BZIP: "application/x-bzip"; /** BZip2 归档(.bz2) */
|
|
617
772
|
readonly BZIP2: "application/x-bzip2"; /** 7-Zip 压缩文件(.7z) */
|
|
618
|
-
readonly SEVEN_Z: "application/x-7z-compressed"; /**
|
|
773
|
+
readonly SEVEN_Z: "application/x-7z-compressed"; /** RAR 压缩文件(.rar) */
|
|
774
|
+
readonly RAR: "application/vnd.rar"; /** 通用二进制数据(默认类型) */
|
|
619
775
|
readonly OCTET_STREAM: "application/octet-stream"; /** JSON 数据格式(.json) */
|
|
620
776
|
readonly JSON: "application/json"; /** JSON-LD 格式(.jsonld) */
|
|
621
777
|
readonly LD_JSON: "application/ld+json"; /** Java 归档文件(.jar) */
|
|
622
|
-
readonly JAR: "application/java-archive"; /**
|
|
778
|
+
readonly JAR: "application/java-archive"; /** WebAssembly 二进制指令格式(.wasm) */
|
|
779
|
+
readonly WASM: "application/wasm"; /** MS 嵌入式 OpenType 字体(.eot) */
|
|
623
780
|
readonly EOT: "application/vnd.ms-fontobject"; /** OpenType 字体(.otf) */
|
|
624
|
-
readonly OTF: "font/otf"; /**
|
|
781
|
+
readonly OTF: "font/otf"; /** WOFF 字体(.woff) */
|
|
782
|
+
readonly WOFF: "font/woff"; /** WOFF2 字体(.woff2) */
|
|
783
|
+
readonly WOFF2: "font/woff2"; /** TrueType 字体(.ttf) */
|
|
784
|
+
readonly TTF: "font/ttf"; /** Excel 97-2003 工作簿(.xls) */
|
|
625
785
|
readonly XLS: "application/vnd.ms-excel"; /** Microsoft XPS 文档(.xps) */
|
|
626
786
|
readonly XPS: "application/vnd.ms-xpsdocument"; /** Word 启用宏文档(.docm) */
|
|
627
787
|
readonly DOCM: "application/vnd.ms-word.document.macroEnabled.12";
|
|
@@ -650,7 +810,7 @@ declare class NumberUtil {
|
|
|
650
810
|
static within(input: number, interval: [number, number], includeLeft?: boolean, includeRight?: boolean): boolean;
|
|
651
811
|
}
|
|
652
812
|
//#endregion
|
|
653
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
813
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/typed-array.d.ts
|
|
654
814
|
/**
|
|
655
815
|
Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
|
656
816
|
|
|
@@ -658,7 +818,24 @@ Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScrip
|
|
|
658
818
|
*/
|
|
659
819
|
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
660
820
|
//#endregion
|
|
661
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
821
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/characters.d.ts
|
|
822
|
+
/**
|
|
823
|
+
Matches any digit as a string ('0'-'9').
|
|
824
|
+
|
|
825
|
+
@example
|
|
826
|
+
```
|
|
827
|
+
import type {DigitCharacter} from 'type-fest';
|
|
828
|
+
|
|
829
|
+
const a: DigitCharacter = '0'; // Valid
|
|
830
|
+
// @ts-expect-error
|
|
831
|
+
const b: DigitCharacter = 0; // Invalid
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
@category Type
|
|
835
|
+
*/
|
|
836
|
+
type DigitCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
837
|
+
//#endregion
|
|
838
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
662
839
|
/**
|
|
663
840
|
Convert a union type to an intersection type.
|
|
664
841
|
|
|
@@ -687,7 +864,7 @@ Union extends unknown // The union type is used as the only argument to a functi
|
|
|
687
864
|
) extends ((mergedIntersection: infer Intersection) => void) // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
688
865
|
? Intersection & Union : never;
|
|
689
866
|
//#endregion
|
|
690
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
867
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/keys-of-union.d.ts
|
|
691
868
|
/**
|
|
692
869
|
Create a union of all keys from a given type, even those exclusive to specific union members.
|
|
693
870
|
|
|
@@ -728,7 +905,7 @@ type AllKeys = KeysOfUnion<Union>;
|
|
|
728
905
|
type KeysOfUnion<ObjectType> = // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
|
|
729
906
|
keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
|
|
730
907
|
//#endregion
|
|
731
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
908
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-any.d.ts
|
|
732
909
|
/**
|
|
733
910
|
Returns a boolean for whether the given type is `any`.
|
|
734
911
|
|
|
@@ -759,7 +936,7 @@ const anyA = get(anyObject, 'a');
|
|
|
759
936
|
*/
|
|
760
937
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
761
938
|
//#endregion
|
|
762
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
939
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
763
940
|
/**
|
|
764
941
|
Returns a boolean for whether the given key is an optional key of type.
|
|
765
942
|
|
|
@@ -802,7 +979,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
802
979
|
*/
|
|
803
980
|
type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
|
|
804
981
|
//#endregion
|
|
805
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
982
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
806
983
|
/**
|
|
807
984
|
Extract all optional keys from the given type.
|
|
808
985
|
|
|
@@ -840,7 +1017,7 @@ type OptionalKeysOf<Type extends object> = Type extends unknown // For distribut
|
|
|
840
1017
|
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
841
1018
|
: never;
|
|
842
1019
|
//#endregion
|
|
843
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1020
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
844
1021
|
/**
|
|
845
1022
|
Extract all required keys from the given type.
|
|
846
1023
|
|
|
@@ -874,7 +1051,7 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
|
874
1051
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
875
1052
|
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
876
1053
|
//#endregion
|
|
877
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1054
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-never.d.ts
|
|
878
1055
|
/**
|
|
879
1056
|
Returns a boolean for whether the given type is `never`.
|
|
880
1057
|
|
|
@@ -930,7 +1107,7 @@ type B = IsTrueFixed<never>;
|
|
|
930
1107
|
*/
|
|
931
1108
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
932
1109
|
//#endregion
|
|
933
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1110
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/if.d.ts
|
|
934
1111
|
/**
|
|
935
1112
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
936
1113
|
|
|
@@ -1025,7 +1202,7 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
|
1025
1202
|
*/
|
|
1026
1203
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
1027
1204
|
//#endregion
|
|
1028
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1205
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/unknown-array.d.ts
|
|
1029
1206
|
/**
|
|
1030
1207
|
Represents an array with `unknown` value.
|
|
1031
1208
|
|
|
@@ -1052,7 +1229,7 @@ type C = IsArray<string>;
|
|
|
1052
1229
|
*/
|
|
1053
1230
|
type UnknownArray = readonly unknown[];
|
|
1054
1231
|
//#endregion
|
|
1055
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1232
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/type.d.ts
|
|
1056
1233
|
/**
|
|
1057
1234
|
Returns a boolean for whether A is false.
|
|
1058
1235
|
|
|
@@ -1116,7 +1293,7 @@ Indicates the value of `exactOptionalPropertyTypes` compiler option.
|
|
|
1116
1293
|
*/
|
|
1117
1294
|
type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
|
|
1118
1295
|
//#endregion
|
|
1119
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1296
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/array.d.ts
|
|
1120
1297
|
/**
|
|
1121
1298
|
Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
|
|
1122
1299
|
|
|
@@ -1158,7 +1335,7 @@ type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extend
|
|
|
1158
1335
|
: First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
|
|
1159
1336
|
: never; // Should never happen
|
|
1160
1337
|
//#endregion
|
|
1161
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1338
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/numeric.d.ts
|
|
1162
1339
|
type _Numeric = number | bigint;
|
|
1163
1340
|
type Zero = 0 | 0n;
|
|
1164
1341
|
/**
|
|
@@ -1203,7 +1380,7 @@ type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
|
|
|
1203
1380
|
//#region ../../node_modules/.pnpm/tagged-tag@1.0.0/node_modules/tagged-tag/index.d.ts
|
|
1204
1381
|
declare const tag: unique symbol;
|
|
1205
1382
|
//#endregion
|
|
1206
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1383
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/tagged.d.ts
|
|
1207
1384
|
// eslint-disable-next-line type-fest/require-exported-types
|
|
1208
1385
|
type TagContainer<Token> = {
|
|
1209
1386
|
readonly [tag]: Token;
|
|
@@ -1375,7 +1552,7 @@ type Person = {
|
|
|
1375
1552
|
@deprecated Use {@link Tagged} instead
|
|
1376
1553
|
*/
|
|
1377
1554
|
//#endregion
|
|
1378
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1555
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-literal.d.ts
|
|
1379
1556
|
/**
|
|
1380
1557
|
Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
|
|
1381
1558
|
|
|
@@ -1437,7 +1614,7 @@ type _IsStringLiteral<S> = // If `T` is an infinite string type (e.g., `on${stri
|
|
|
1437
1614
|
// and since `{}` extends index signatures, the result becomes `false`.
|
|
1438
1615
|
S extends string ? {} extends Record<S, never> ? false : true : false;
|
|
1439
1616
|
//#endregion
|
|
1440
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1617
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/tuple-of.d.ts
|
|
1441
1618
|
/**
|
|
1442
1619
|
Create a tuple type of the specified length with elements of the specified type.
|
|
1443
1620
|
|
|
@@ -1465,7 +1642,7 @@ type ZeroToFour = Range<0, 5>;
|
|
|
1465
1642
|
//=> '0' | '1' | '2' | '3' | '4'
|
|
1466
1643
|
|
|
1467
1644
|
type ThreeToEight = Range<3, 9>;
|
|
1468
|
-
//=> '
|
|
1645
|
+
//=> '3' | '4' | '5' | '6' | '7' | '8'
|
|
1469
1646
|
```
|
|
1470
1647
|
|
|
1471
1648
|
Note: If the specified length is the non-literal `number` type, the result will not be a tuple but a regular array.
|
|
@@ -1498,14 +1675,27 @@ type EmptyTuple = TupleOf<-3, string>;
|
|
|
1498
1675
|
//=> []
|
|
1499
1676
|
```
|
|
1500
1677
|
|
|
1678
|
+
Note: If the specified length has a decimal part, the decimal part will be ignored.
|
|
1679
|
+
|
|
1680
|
+
@example
|
|
1681
|
+
```
|
|
1682
|
+
import type {TupleOf} from 'type-fest';
|
|
1683
|
+
|
|
1684
|
+
type DecimalLength = TupleOf<3.5, string>;
|
|
1685
|
+
//=> [string, string, string]
|
|
1686
|
+
```
|
|
1687
|
+
|
|
1501
1688
|
Note: If you need a readonly tuple, simply wrap this type with `Readonly`, for example, to create `readonly [number, number, number]` use `Readonly<TupleOf<3, number>>`.
|
|
1502
1689
|
|
|
1503
1690
|
@category Array
|
|
1504
1691
|
*/
|
|
1505
|
-
type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill
|
|
1506
|
-
type _TupleOf<
|
|
1692
|
+
type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill>, Fill[], []>;
|
|
1693
|
+
type _TupleOf<Length extends number, Fill> = number extends Length ? Fill[] : BuildTupleDigitByDigit<`${Length}`, Fill>;
|
|
1694
|
+
type BuildTupleDigitByDigit<Length extends string, Fill, Accumulator extends UnknownArray = []> = Length extends `${infer First extends DigitCharacter}${infer Rest}` ? BuildTupleDigitByDigit<Rest, Fill, [...RepeatTupleTenTimes<Accumulator>, ...DigitTupleOf<First, Fill>]> : Accumulator;
|
|
1695
|
+
type RepeatTupleTenTimes<Tuple extends UnknownArray> = [...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple];
|
|
1696
|
+
type DigitTupleOf<Digit extends DigitCharacter, Fill> = [[], [Fill], [Fill, Fill], [Fill, Fill, Fill], [Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill]][Digit];
|
|
1507
1697
|
//#endregion
|
|
1508
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1698
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/simplify.d.ts
|
|
1509
1699
|
/**
|
|
1510
1700
|
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
1511
1701
|
|
|
@@ -1566,7 +1756,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
1566
1756
|
*/
|
|
1567
1757
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
1568
1758
|
//#endregion
|
|
1569
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1759
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-equal.d.ts
|
|
1570
1760
|
/**
|
|
1571
1761
|
Returns a boolean for whether the two given types are equal.
|
|
1572
1762
|
|
|
@@ -1597,7 +1787,7 @@ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false
|
|
|
1597
1787
|
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
1598
1788
|
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
1599
1789
|
//#endregion
|
|
1600
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1790
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
1601
1791
|
/**
|
|
1602
1792
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
1603
1793
|
|
|
@@ -1691,7 +1881,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
1691
1881
|
*/
|
|
1692
1882
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
1693
1883
|
//#endregion
|
|
1694
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1884
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
1695
1885
|
/**
|
|
1696
1886
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
1697
1887
|
|
|
@@ -1739,7 +1929,7 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
1739
1929
|
*/
|
|
1740
1930
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
1741
1931
|
//#endregion
|
|
1742
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
1932
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/merge.d.ts
|
|
1743
1933
|
// Merges two objects without worrying about index signatures.
|
|
1744
1934
|
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
|
|
1745
1935
|
/**
|
|
@@ -1811,7 +2001,7 @@ type Merge<Destination, Source> = Destination extends unknown // For distributin
|
|
|
1811
2001
|
// Should never happen
|
|
1812
2002
|
type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
1813
2003
|
//#endregion
|
|
1814
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2004
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/object.d.ts
|
|
1815
2005
|
/**
|
|
1816
2006
|
Works similar to the built-in `Pick` utility type, except for the following differences:
|
|
1817
2007
|
- Distributes over union types and allows picking keys from any member of the union type.
|
|
@@ -1902,8 +2092,9 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
1902
2092
|
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
1903
2093
|
```
|
|
1904
2094
|
*/
|
|
1905
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> =
|
|
1906
|
-
|
|
2095
|
+
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
2096
|
+
? Result : never;
|
|
2097
|
+
type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key] }>>>;
|
|
1907
2098
|
/**
|
|
1908
2099
|
Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
|
|
1909
2100
|
|
|
@@ -1933,7 +2124,7 @@ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined
|
|
|
1933
2124
|
*/
|
|
1934
2125
|
type CollapseLiterals<T> = {} extends T ? T : T extends infer U & {} ? U : T;
|
|
1935
2126
|
//#endregion
|
|
1936
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2127
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/some-extend.d.ts
|
|
1937
2128
|
/**
|
|
1938
2129
|
@see {@link SomeExtend}
|
|
1939
2130
|
*/
|
|
@@ -2015,7 +2206,7 @@ type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOpt
|
|
|
2015
2206
|
type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
|
|
2016
2207
|
? true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false, false, false>;
|
|
2017
2208
|
//#endregion
|
|
2018
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2209
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/or-all.d.ts
|
|
2019
2210
|
/**
|
|
2020
2211
|
Returns a boolean for whether any of the given elements is `true`.
|
|
2021
2212
|
|
|
@@ -2086,7 +2277,7 @@ Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in a
|
|
|
2086
2277
|
*/
|
|
2087
2278
|
type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
|
|
2088
2279
|
//#endregion
|
|
2089
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2280
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/or.d.ts
|
|
2090
2281
|
/**
|
|
2091
2282
|
Returns a boolean for whether either of two given types is `true`.
|
|
2092
2283
|
|
|
@@ -2166,7 +2357,7 @@ type G = Or<never, never>;
|
|
|
2166
2357
|
*/
|
|
2167
2358
|
type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
|
|
2168
2359
|
//#endregion
|
|
2169
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2360
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/all-extend.d.ts
|
|
2170
2361
|
/**
|
|
2171
2362
|
@see {@link AllExtend}
|
|
2172
2363
|
*/
|
|
@@ -2252,7 +2443,7 @@ type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptio
|
|
|
2252
2443
|
type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
|
|
2253
2444
|
? _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true, false, false>;
|
|
2254
2445
|
//#endregion
|
|
2255
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2446
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/and-all.d.ts
|
|
2256
2447
|
/**
|
|
2257
2448
|
Returns a boolean for whether all of the given elements are `true`.
|
|
2258
2449
|
|
|
@@ -2326,7 +2517,7 @@ Note: `AndAll<[]>` evaluates to `true` due to the concept of [vacuous truth](htt
|
|
|
2326
2517
|
*/
|
|
2327
2518
|
type AndAll<T extends readonly boolean[]> = AllExtend<T, true>;
|
|
2328
2519
|
//#endregion
|
|
2329
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2520
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/and.d.ts
|
|
2330
2521
|
/**
|
|
2331
2522
|
Returns a boolean for whether two given types are both `true`.
|
|
2332
2523
|
|
|
@@ -2406,7 +2597,7 @@ type G = And<never, never>;
|
|
|
2406
2597
|
*/
|
|
2407
2598
|
type And<A extends boolean, B extends boolean> = AndAll<[A, B]>;
|
|
2408
2599
|
//#endregion
|
|
2409
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2600
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/except.d.ts
|
|
2410
2601
|
/**
|
|
2411
2602
|
Filter out keys from an object.
|
|
2412
2603
|
|
|
@@ -2504,7 +2695,7 @@ type PostPayloadFixed = Except<UserData, 'email'>;
|
|
|
2504
2695
|
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
2505
2696
|
type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
|
|
2506
2697
|
//#endregion
|
|
2507
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2698
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/exclude-exactly.d.ts
|
|
2508
2699
|
/**
|
|
2509
2700
|
A stricter version of `Exclude<T, U>` that excludes types only when they are exactly identical.
|
|
2510
2701
|
|
|
@@ -2542,7 +2733,7 @@ type _ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Delete, Union extends unkn
|
|
|
2542
2733
|
// because `Union` cannot be `any` or `never` here.
|
|
2543
2734
|
Union, Union>;
|
|
2544
2735
|
//#endregion
|
|
2545
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2736
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-member.d.ts
|
|
2546
2737
|
/**
|
|
2547
2738
|
Returns an arbitrary member of a union type.
|
|
2548
2739
|
|
|
@@ -2599,7 +2790,7 @@ type LastNever = UnionMember<never>;
|
|
|
2599
2790
|
*/
|
|
2600
2791
|
type UnionMember<T> = IsNever<T> extends true ? never : UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
|
|
2601
2792
|
//#endregion
|
|
2602
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2793
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
2603
2794
|
/**
|
|
2604
2795
|
Convert a union type into an unordered tuple type of its elements.
|
|
2605
2796
|
|
|
@@ -2639,7 +2830,7 @@ type UnionToTuple<Union> = _UnionToTuple<Union> extends infer Result extends Unk
|
|
|
2639
2830
|
// Nudges the compiler that `UnionToTuple` always yields an array.
|
|
2640
2831
|
type _UnionToTuple<Union, Accumulator extends UnknownArray = [], Member = UnionMember<Union>> = IsNever<Union> extends true ? Accumulator : _UnionToTuple<ExcludeExactly<Union, Member>, [Member, ...Accumulator]>;
|
|
2641
2832
|
//#endregion
|
|
2642
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2833
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/set-optional.d.ts
|
|
2643
2834
|
/**
|
|
2644
2835
|
Create a type that makes the given keys optional, while keeping the remaining keys as is.
|
|
2645
2836
|
|
|
@@ -2667,7 +2858,7 @@ type _SetOptional<BaseType, Keys extends keyof BaseType> = BaseType extends unkn
|
|
|
2667
2858
|
Except<BaseType, Keys> // Pick the keys that should be mutable from the base type and make them mutable.
|
|
2668
2859
|
& Partial<HomomorphicPick<BaseType, Keys>>> : never;
|
|
2669
2860
|
//#endregion
|
|
2670
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2861
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/value-of.d.ts
|
|
2671
2862
|
/**
|
|
2672
2863
|
Create a union of the given object's values, and optionally specify which keys to get the values from.
|
|
2673
2864
|
|
|
@@ -2691,7 +2882,7 @@ type C = ValueOf<{id: number; name: string; active: boolean}, 'id' | 'name'>;
|
|
|
2691
2882
|
*/
|
|
2692
2883
|
type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
|
|
2693
2884
|
//#endregion
|
|
2694
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2885
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/split.d.ts
|
|
2695
2886
|
/**
|
|
2696
2887
|
Split options.
|
|
2697
2888
|
|
|
@@ -2748,7 +2939,7 @@ type SplitHelper<S extends string, Delimiter extends string, Options extends Req
|
|
|
2748
2939
|
: string[] : never // Should never happen
|
|
2749
2940
|
: never; // Should never happen
|
|
2750
2941
|
//#endregion
|
|
2751
|
-
//#region ../../node_modules/.pnpm/type-fest@5.
|
|
2942
|
+
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/replace.d.ts
|
|
2752
2943
|
type ReplaceOptions = {
|
|
2753
2944
|
all?: boolean;
|
|
2754
2945
|
};
|
|
@@ -3304,7 +3495,18 @@ declare class ObjectUtil {
|
|
|
3304
3495
|
* @returns 键数组
|
|
3305
3496
|
* @example
|
|
3306
3497
|
* ```ts
|
|
3498
|
+
* // 重载 1: string
|
|
3499
|
+
* ObjectUtil.keys("abc"); // ["0", "1", "2"]
|
|
3500
|
+
*
|
|
3501
|
+
* // 重载 2: ArrayLike
|
|
3502
|
+
* ObjectUtil.keys([10, 20]); // ["0", "1"]
|
|
3503
|
+
*
|
|
3504
|
+
* // 重载 3: PlainObject
|
|
3307
3505
|
* ObjectUtil.keys({ a: 1, b: 2 }); // ["a", "b"]
|
|
3506
|
+
*
|
|
3507
|
+
* // 重载 4: AnyObject
|
|
3508
|
+
* const anyObj = { x: 1, y: 2 } as Record<string, unknown>;
|
|
3509
|
+
* ObjectUtil.keys(anyObj); // ["x", "y"]
|
|
3308
3510
|
* ```
|
|
3309
3511
|
*/
|
|
3310
3512
|
static keys<const S extends string>(string: S): UnionToTuple<Range<0, Split<S, "">["length"]>>;
|
|
@@ -3318,7 +3520,18 @@ declare class ObjectUtil {
|
|
|
3318
3520
|
* @returns 值数组
|
|
3319
3521
|
* @example
|
|
3320
3522
|
* ```ts
|
|
3523
|
+
* // 重载 1: string
|
|
3524
|
+
* ObjectUtil.values("abc"); // ["a", "b", "c"]
|
|
3525
|
+
*
|
|
3526
|
+
* // 重载 2: ArrayLike
|
|
3527
|
+
* ObjectUtil.values([10, 20]); // [10, 20]
|
|
3528
|
+
*
|
|
3529
|
+
* // 重载 3: PlainObject
|
|
3321
3530
|
* ObjectUtil.values({ a: 1, b: 2 }); // [1, 2]
|
|
3531
|
+
*
|
|
3532
|
+
* // 重载 4: AnyObject
|
|
3533
|
+
* const anyObj = { x: 1, y: 2 } as Record<string, unknown>;
|
|
3534
|
+
* ObjectUtil.values(anyObj); // [1, 2]
|
|
3322
3535
|
* ```
|
|
3323
3536
|
*/
|
|
3324
3537
|
static values<S extends string>(string: S): Split<S, "">;
|
|
@@ -3332,7 +3545,18 @@ declare class ObjectUtil {
|
|
|
3332
3545
|
* @returns 键值对数组
|
|
3333
3546
|
* @example
|
|
3334
3547
|
* ```ts
|
|
3548
|
+
* // 重载 1: string
|
|
3549
|
+
* ObjectUtil.entries("ab"); // [["0", "a"], ["1", "b"]]
|
|
3550
|
+
*
|
|
3551
|
+
* // 重载 2: readonly array
|
|
3552
|
+
* ObjectUtil.entries([10, 20] as const); // [["0", 10], ["1", 20]]
|
|
3553
|
+
*
|
|
3554
|
+
* // 重载 3: PlainObject
|
|
3335
3555
|
* ObjectUtil.entries({ a: 1 }); // [["a", 1]]
|
|
3556
|
+
*
|
|
3557
|
+
* // 重载 4: AnyObject
|
|
3558
|
+
* const anyObj = { x: 1 } as Record<string, unknown>;
|
|
3559
|
+
* ObjectUtil.entries(anyObj); // [["x", 1]]
|
|
3336
3560
|
* ```
|
|
3337
3561
|
*/
|
|
3338
3562
|
static entries<const S extends string>(string: S): TupleToEntries<Split<S, "">>;
|
|
@@ -3349,7 +3573,10 @@ declare class ObjectUtil {
|
|
|
3349
3573
|
* @example
|
|
3350
3574
|
* ```ts
|
|
3351
3575
|
* const obj = { a: 1, b: 2 };
|
|
3576
|
+
*
|
|
3352
3577
|
* ObjectUtil.entriesMap(obj, (k, v) => [k, v * 2]); // { a: 2, b: 4 }
|
|
3578
|
+
*
|
|
3579
|
+
* ObjectUtil.entriesMap(obj, (k, v) => [`prefix_${String(k)}`, `${v}x`]); // { prefix_a: "1x", prefix_b: "2x" }
|
|
3353
3580
|
* ```
|
|
3354
3581
|
*/
|
|
3355
3582
|
static entriesMap<O extends PlainObject, NK extends PropertyKey, NV>(plainObject: O, toEntry: (key: keyof O, value: O[keyof O]) => [NK, NV]): PlainObject<NK, NV>;
|
|
@@ -3361,7 +3588,12 @@ declare class ObjectUtil {
|
|
|
3361
3588
|
* @returns 包含指定属性的新对象
|
|
3362
3589
|
* @example
|
|
3363
3590
|
* ```ts
|
|
3591
|
+
* // 重载 1: PlainObject
|
|
3364
3592
|
* ObjectUtil.pick({ a: 1, b: 2 }, ["a"]); // { a: 1 }
|
|
3593
|
+
*
|
|
3594
|
+
* // 重载 2: AnyObject
|
|
3595
|
+
* const anyObj = { x: 1, y: 2 } as Record<string, unknown>;
|
|
3596
|
+
* ObjectUtil.pick(anyObj, ["x"]); // { x: 1 }
|
|
3365
3597
|
* ```
|
|
3366
3598
|
*/
|
|
3367
3599
|
static pick<O extends PlainObject, K extends keyof O>(plainObject: O, keys: readonly K[]): Pick<O, K>;
|
|
@@ -3374,7 +3606,12 @@ declare class ObjectUtil {
|
|
|
3374
3606
|
* @returns 排除指定属性后的新对象
|
|
3375
3607
|
* @example
|
|
3376
3608
|
* ```ts
|
|
3609
|
+
* // 重载 1: PlainObject
|
|
3377
3610
|
* ObjectUtil.omit({ a: 1, b: 2 }, ["a"]); // { b: 2 }
|
|
3611
|
+
*
|
|
3612
|
+
* // 重载 2: AnyObject
|
|
3613
|
+
* const anyObj = { x: 1, y: 2 } as Record<string, unknown>;
|
|
3614
|
+
* ObjectUtil.omit(anyObj, ["x"]); // { y: 2 }
|
|
3378
3615
|
* ```
|
|
3379
3616
|
*/
|
|
3380
3617
|
static omit<O extends PlainObject, K extends keyof O>(plainObject: O, keys: readonly K[]): Omit<O, K>;
|
|
@@ -3386,8 +3623,13 @@ declare class ObjectUtil {
|
|
|
3386
3623
|
* @returns 键值互换后的对象
|
|
3387
3624
|
* @example
|
|
3388
3625
|
* ```ts
|
|
3626
|
+
* // 重载 1: Record<keyof O, PropertyKey>
|
|
3389
3627
|
* const obj = { a: "1", b: 2 };
|
|
3390
3628
|
* ObjectUtil.invert(obj); // { "1": "a", 2: "b" }
|
|
3629
|
+
*
|
|
3630
|
+
* // 重载 2: AnyObject
|
|
3631
|
+
* const anyObj = { x: Symbol.for("s"), y: true } as Record<string, unknown>;
|
|
3632
|
+
* ObjectUtil.invert(anyObj); // { [Symbol.for("s")]: "x" }
|
|
3391
3633
|
* ```
|
|
3392
3634
|
*/
|
|
3393
3635
|
static invert<const O extends Record<keyof O, PropertyKey>>(plainObject: O): Invert<O>;
|
|
@@ -3400,8 +3642,13 @@ declare class ObjectUtil {
|
|
|
3400
3642
|
* @returns 压平后的对象
|
|
3401
3643
|
* @example
|
|
3402
3644
|
* ```ts
|
|
3403
|
-
*
|
|
3404
|
-
*
|
|
3645
|
+
* // 重载 1: PlainObject
|
|
3646
|
+
* const plainObj = { a: { b: 1 } };
|
|
3647
|
+
* ObjectUtil.crush(plainObj); // { "a.b": 1 }
|
|
3648
|
+
*
|
|
3649
|
+
* // 重载 2: AnyObject
|
|
3650
|
+
* const anyObj = { list: [{ id: 1 }] } as Record<string, unknown>;
|
|
3651
|
+
* ObjectUtil.crush(anyObj); // { "list.0.id": 1 }
|
|
3405
3652
|
* ```
|
|
3406
3653
|
*/
|
|
3407
3654
|
static crush<T extends PlainObject>(plainObject: T): Crush<T>;
|
|
@@ -3413,8 +3660,14 @@ declare class ObjectUtil {
|
|
|
3413
3660
|
* @returns 键数组
|
|
3414
3661
|
* @example
|
|
3415
3662
|
* ```ts
|
|
3416
|
-
*
|
|
3417
|
-
*
|
|
3663
|
+
* // 重载 1: PlainObject
|
|
3664
|
+
* enum StringEnum { A = "a", B = "b" }
|
|
3665
|
+
* ObjectUtil.enumKeys(StringEnum); // ["A", "B"]
|
|
3666
|
+
*
|
|
3667
|
+
* // 重载 2: AnyObject
|
|
3668
|
+
* enum NumberEnum { A, B }
|
|
3669
|
+
* const anyEnum = NumberEnum as Record<string, unknown>;
|
|
3670
|
+
* ObjectUtil.enumKeys(anyEnum); // ["A", "B"]
|
|
3418
3671
|
* ```
|
|
3419
3672
|
*/
|
|
3420
3673
|
static enumKeys<E extends PlainObject>(enumeration: E): (keyof E)[];
|
|
@@ -3426,8 +3679,14 @@ declare class ObjectUtil {
|
|
|
3426
3679
|
* @returns 值数组
|
|
3427
3680
|
* @example
|
|
3428
3681
|
* ```ts
|
|
3429
|
-
*
|
|
3430
|
-
*
|
|
3682
|
+
* // 重载 1: PlainObject
|
|
3683
|
+
* enum StringEnum { A = "a", B = "b" }
|
|
3684
|
+
* ObjectUtil.enumValues(StringEnum); // ["a", "b"]
|
|
3685
|
+
*
|
|
3686
|
+
* // 重载 2: AnyObject
|
|
3687
|
+
* enum NumberEnum { A, B }
|
|
3688
|
+
* const anyEnum = NumberEnum as Record<string, unknown>;
|
|
3689
|
+
* ObjectUtil.enumValues(anyEnum); // [0, 1]
|
|
3431
3690
|
* ```
|
|
3432
3691
|
*/
|
|
3433
3692
|
static enumValues<E extends PlainObject>(enumeration: E): UnionToTuple<ValueOf<E>>;
|
|
@@ -3439,8 +3698,14 @@ declare class ObjectUtil {
|
|
|
3439
3698
|
* @returns 键值对数组
|
|
3440
3699
|
* @example
|
|
3441
3700
|
* ```ts
|
|
3442
|
-
*
|
|
3443
|
-
*
|
|
3701
|
+
* // 重载 1: PlainObject
|
|
3702
|
+
* enum StringEnum { A = "a", B = "b" }
|
|
3703
|
+
* ObjectUtil.enumEntries(StringEnum); // [["A", "a"], ["B", "b"]]
|
|
3704
|
+
*
|
|
3705
|
+
* // 重载 2: AnyObject
|
|
3706
|
+
* enum NumberEnum { A, B }
|
|
3707
|
+
* const anyEnum = NumberEnum as Record<string, unknown>;
|
|
3708
|
+
* ObjectUtil.enumEntries(anyEnum); // [["A", 0], ["B", 1]]
|
|
3444
3709
|
* ```
|
|
3445
3710
|
*/
|
|
3446
3711
|
static enumEntries<E extends PlainObject>(enumeration: E): [keyof E, E[keyof E]][];
|
|
@@ -3452,6 +3717,39 @@ declare class ObjectUtil {
|
|
|
3452
3717
|
* 字符串工具类
|
|
3453
3718
|
*/
|
|
3454
3719
|
declare class StringUtil {
|
|
3720
|
+
/**
|
|
3721
|
+
* 将任意值转换为字符串
|
|
3722
|
+
* - 当传入数值字面量时,返回对应的字符串字面量类型
|
|
3723
|
+
*
|
|
3724
|
+
* @param candidate 待转换的值
|
|
3725
|
+
* @param checkEmpty 是否检查空值(`null` / `undefined` / 空白字符串),默认为 `true`
|
|
3726
|
+
* @returns 转换后的字符串
|
|
3727
|
+
* @example
|
|
3728
|
+
* ```ts
|
|
3729
|
+
* // 重载 1: null / undefined + checkEmpty = true (默认) → ""
|
|
3730
|
+
* StringUtil.cast(null); // ""
|
|
3731
|
+
* StringUtil.cast(undefined); // ""
|
|
3732
|
+
* StringUtil.cast(""); // ""
|
|
3733
|
+
* StringUtil.cast(" "); // ""
|
|
3734
|
+
*
|
|
3735
|
+
* // 重载 2: null / undefined + checkEmpty = false → "null" / "undefined"
|
|
3736
|
+
* StringUtil.cast(null, false); // "null" (类型为 "null")
|
|
3737
|
+
* StringUtil.cast(undefined, false); // "undefined" (类型为 "undefined")
|
|
3738
|
+
*
|
|
3739
|
+
* // 重载 3: 原始类型 → 字符串字面量类型
|
|
3740
|
+
* StringUtil.cast(123); // "123" (类型为 "123")
|
|
3741
|
+
* StringUtil.cast("hello"); // "hello" (类型为 "hello")
|
|
3742
|
+
* StringUtil.cast(true); // "true" (类型为 "true")
|
|
3743
|
+
* StringUtil.cast(42n); // "42" (类型为 "42")
|
|
3744
|
+
*
|
|
3745
|
+
* // 重载 4: 其他类型 → string
|
|
3746
|
+
* StringUtil.cast(Symbol("foo")); // "Symbol(foo)" (类型为 string)
|
|
3747
|
+
* ```
|
|
3748
|
+
*/
|
|
3749
|
+
static cast<T extends null | undefined>(candidate: T, checkEmpty?: true): "";
|
|
3750
|
+
static cast<T extends null | undefined>(candidate: T, checkEmpty: false): `${T}`;
|
|
3751
|
+
static cast<T extends string | number | bigint | boolean>(candidate: T, checkEmpty?: boolean): `${T}`;
|
|
3752
|
+
static cast(candidate: unknown, checkEmpty?: boolean): string;
|
|
3455
3753
|
/**
|
|
3456
3754
|
* 从字符串中提取数字字符串
|
|
3457
3755
|
* - 移除非数字字符,保留符号和小数点
|
|
@@ -3474,7 +3772,10 @@ declare class StringUtil {
|
|
|
3474
3772
|
* @returns 转换后的小写字符串类型,如果输入无效则返回空字符串类型 ""
|
|
3475
3773
|
* @example
|
|
3476
3774
|
* ```ts
|
|
3775
|
+
* // 重载 1: 输入 string
|
|
3477
3776
|
* StringUtil.toLowerCase("HELLO"); // "hello"
|
|
3777
|
+
*
|
|
3778
|
+
* // 重载 2: 输入 unknown
|
|
3478
3779
|
* StringUtil.toLowerCase(null); // ""
|
|
3479
3780
|
* ```
|
|
3480
3781
|
*/
|
|
@@ -3489,7 +3790,10 @@ declare class StringUtil {
|
|
|
3489
3790
|
* @returns 转换后的大写字符串,如果输入无效则返回空字符串
|
|
3490
3791
|
* @example
|
|
3491
3792
|
* ```ts
|
|
3793
|
+
* // 重载 1: 输入 string
|
|
3492
3794
|
* StringUtil.toUpperCase("hello"); // "HELLO"
|
|
3795
|
+
*
|
|
3796
|
+
* // 重载 2: 输入 unknown
|
|
3493
3797
|
* StringUtil.toUpperCase(null); // ""
|
|
3494
3798
|
* ```
|
|
3495
3799
|
*/
|
|
@@ -3543,8 +3847,12 @@ declare class StringUtil {
|
|
|
3543
3847
|
* @returns 解析后的对象 或 回退值
|
|
3544
3848
|
* @example
|
|
3545
3849
|
* ```ts
|
|
3546
|
-
*
|
|
3547
|
-
* StringUtil.toJson(
|
|
3850
|
+
* // 重载 1: 无 fallback
|
|
3851
|
+
* StringUtil.toJson<{ a: number }>("{\"a\":1}"); // { a: 1 }
|
|
3852
|
+
* StringUtil.toJson("invalid"); // undefined
|
|
3853
|
+
*
|
|
3854
|
+
* // 重载 2: 有 fallback
|
|
3855
|
+
* StringUtil.toJson<{ a: number }>("invalid", { a: 0 }); // { a: 0 }
|
|
3548
3856
|
* ```
|
|
3549
3857
|
*/
|
|
3550
3858
|
static toJson<D extends AnyObject = AnyObject>(input: string | null | undefined): D | undefined;
|
|
@@ -3559,7 +3867,10 @@ declare class StringUtil {
|
|
|
3559
3867
|
* @returns 分割后的数组
|
|
3560
3868
|
* @example
|
|
3561
3869
|
* ```ts
|
|
3870
|
+
* // 重载 1: valueType = "number" (默认)
|
|
3562
3871
|
* StringUtil.toValues("1,2,3"); // [1, 2, 3]
|
|
3872
|
+
*
|
|
3873
|
+
* // 重载 2: valueType = "string"
|
|
3563
3874
|
* StringUtil.toValues("a-b-c", "string", "-"); // ["a", "b", "c"]
|
|
3564
3875
|
* ```
|
|
3565
3876
|
*/
|
|
@@ -3627,10 +3938,28 @@ declare class StringUtil {
|
|
|
3627
3938
|
* 主题工具类
|
|
3628
3939
|
*/
|
|
3629
3940
|
declare class ThemeUtil {
|
|
3941
|
+
/**
|
|
3942
|
+
* 固定主题类型(仅亮色/暗色)
|
|
3943
|
+
*
|
|
3944
|
+
* @example
|
|
3945
|
+
* ```ts
|
|
3946
|
+
* ThemeUtil.THEME.LIGHT; // "light"
|
|
3947
|
+
* ThemeUtil.THEME.DARK; // "dark"
|
|
3948
|
+
* ```
|
|
3949
|
+
*/
|
|
3630
3950
|
static readonly THEME: {
|
|
3631
3951
|
readonly LIGHT: "light";
|
|
3632
3952
|
readonly DARK: "dark";
|
|
3633
3953
|
};
|
|
3954
|
+
/**
|
|
3955
|
+
* 主题模式(支持跟随系统)
|
|
3956
|
+
*
|
|
3957
|
+
* @example
|
|
3958
|
+
* ```ts
|
|
3959
|
+
* ThemeUtil.THEME_MODE.SYSTEM; // "system"
|
|
3960
|
+
* ThemeUtil.THEME_MODE.DARK; // "dark"
|
|
3961
|
+
* ```
|
|
3962
|
+
*/
|
|
3634
3963
|
static readonly THEME_MODE: {
|
|
3635
3964
|
readonly LIGHT: "light";
|
|
3636
3965
|
readonly DARK: "dark";
|
|
@@ -3748,8 +4077,12 @@ declare class TreeUtil {
|
|
|
3748
4077
|
* @example
|
|
3749
4078
|
* ```ts
|
|
3750
4079
|
* const tree = [{ id: 1, visible: true, children: [{ id: 2, visible: false }] }];
|
|
3751
|
-
*
|
|
3752
|
-
* //
|
|
4080
|
+
*
|
|
4081
|
+
* // 重载 1: 传入树数组
|
|
4082
|
+
* TreeUtil.filter(tree, (node) => node.visible); // [{ id: 1, visible: true, children: [] }]
|
|
4083
|
+
*
|
|
4084
|
+
* // 重载 2: 传入单个树节点
|
|
4085
|
+
* TreeUtil.filter(tree[0], (node) => node.visible); // { id: 1, visible: true, children: [] }
|
|
3753
4086
|
* ```
|
|
3754
4087
|
*/
|
|
3755
4088
|
static filter<T extends AnyObject, CK extends string = ChildrenKey>(tree: T[], callback: TreeFilterCallback<T>, options?: TreeFilterOptions<T, CK>): T[];
|
|
@@ -3765,8 +4098,14 @@ declare class TreeUtil {
|
|
|
3765
4098
|
* @example
|
|
3766
4099
|
* ```ts
|
|
3767
4100
|
* const tree = [{ id: 1, val: 10, children: [{ id: 2, val: 20 }] }];
|
|
4101
|
+
*
|
|
4102
|
+
* // 重载 1: 传入树数组
|
|
3768
4103
|
* TreeUtil.map(tree, (node) => ({ ...node, val: node.val * 2 }));
|
|
3769
4104
|
* // [{ id: 1, val: 20, children: [{ id: 2, val: 40 }] }]
|
|
4105
|
+
*
|
|
4106
|
+
* // 重载 2: 传入单个树节点
|
|
4107
|
+
* TreeUtil.map(tree[0], (node) => ({ ...node, val: node.val * 2 }));
|
|
4108
|
+
* // { id: 1, val: 20, children: [{ id: 2, val: 40 }] }
|
|
3770
4109
|
* ```
|
|
3771
4110
|
*/
|
|
3772
4111
|
static map<R extends AnyObject, T extends AnyObject, CK extends string = ChildrenKey>(tree: T[], callback: TreeMapCallback<R, T>, options?: TreeMapOptions<T, CK>): TreeLike<R, CK>[];
|
|
@@ -3796,23 +4135,27 @@ declare class TypeUtil {
|
|
|
3796
4135
|
private static isConstructable;
|
|
3797
4136
|
/**
|
|
3798
4137
|
* 检查 value 是否为 string 类型
|
|
4138
|
+
* - 当 `checkEmpty` 为 `true` 时,会先 trim 再判断是否为空
|
|
3799
4139
|
*
|
|
3800
4140
|
* @param value 待检查值
|
|
3801
|
-
* @param checkEmpty
|
|
4141
|
+
* @param checkEmpty 是否检查空字符串(含空白字符串),默认为 `false`
|
|
3802
4142
|
* @returns 是否为字符串
|
|
3803
4143
|
* @example
|
|
3804
4144
|
* ```ts
|
|
3805
4145
|
* TypeUtil.isString("abc"); // true
|
|
3806
4146
|
* TypeUtil.isString(""); // true
|
|
3807
4147
|
* TypeUtil.isString("", true); // false
|
|
4148
|
+
* TypeUtil.isString(" ", true); // false
|
|
4149
|
+
* TypeUtil.isString(" a ", true); // true
|
|
3808
4150
|
* ```
|
|
3809
4151
|
*/
|
|
3810
4152
|
static isString(value: unknown, checkEmpty?: boolean): value is string;
|
|
3811
4153
|
/**
|
|
3812
4154
|
* 检查 value 是否为 number 类型
|
|
4155
|
+
* - 默认会调用 `TypeUtil.isNaN`(内部基于 `Number.isNaN`)过滤掉 `NaN`
|
|
3813
4156
|
*
|
|
3814
4157
|
* @param value 待检查值
|
|
3815
|
-
* @param checkNaN
|
|
4158
|
+
* @param checkNaN 是否检查 `NaN`,默认为 `true`
|
|
3816
4159
|
* @returns 是否为 number
|
|
3817
4160
|
* @example
|
|
3818
4161
|
* ```ts
|
|
@@ -3824,9 +4167,15 @@ declare class TypeUtil {
|
|
|
3824
4167
|
static isNumber(value: unknown, checkNaN?: boolean): value is number;
|
|
3825
4168
|
/**
|
|
3826
4169
|
* 检查 value 是否为 NaN
|
|
4170
|
+
* - 禁止使用全局 `isNaN`,其会先进行隐式数字转换,可能导致误判(例如 `isNaN("foo") === true`)
|
|
4171
|
+
* - 使用 `Number.isNaN` 仅在值本身就是 `NaN` 时返回 `true`,语义更严格且更安全
|
|
3827
4172
|
*
|
|
3828
4173
|
* @param value 待检查值
|
|
3829
4174
|
* @returns 是否为 NaN
|
|
4175
|
+
* @example
|
|
4176
|
+
* ```ts
|
|
4177
|
+
* TypeUtil.isNaN(NaN); // true
|
|
4178
|
+
* ```
|
|
3830
4179
|
*/
|
|
3831
4180
|
static isNaN(value: unknown): value is number;
|
|
3832
4181
|
/**
|
|
@@ -3835,6 +4184,11 @@ declare class TypeUtil {
|
|
|
3835
4184
|
* @param value 待检查值
|
|
3836
4185
|
* @param checkSafe 是否附加安全整数检查
|
|
3837
4186
|
* @returns 是否为整数
|
|
4187
|
+
* @example
|
|
4188
|
+
* ```ts
|
|
4189
|
+
* TypeUtil.isInteger(1); // true
|
|
4190
|
+
* TypeUtil.isInteger(1.1); // false
|
|
4191
|
+
* ```
|
|
3838
4192
|
*/
|
|
3839
4193
|
static isInteger(value: unknown, checkSafe?: boolean): value is number;
|
|
3840
4194
|
/**
|
|
@@ -3843,6 +4197,11 @@ declare class TypeUtil {
|
|
|
3843
4197
|
*
|
|
3844
4198
|
* @param value 待检查值
|
|
3845
4199
|
* @param checkSafe 是否附加安全整数检查
|
|
4200
|
+
* @example
|
|
4201
|
+
* ```ts
|
|
4202
|
+
* TypeUtil.isPositiveInteger(1); // true
|
|
4203
|
+
* TypeUtil.isPositiveInteger(0); // false
|
|
4204
|
+
* ```
|
|
3846
4205
|
*/
|
|
3847
4206
|
static isPositiveInteger(value: unknown, checkSafe?: boolean): value is number;
|
|
3848
4207
|
/**
|
|
@@ -3851,6 +4210,11 @@ declare class TypeUtil {
|
|
|
3851
4210
|
*
|
|
3852
4211
|
* @param value 待检查值
|
|
3853
4212
|
* @param checkSafe 是否附加安全整数检查
|
|
4213
|
+
* @example
|
|
4214
|
+
* ```ts
|
|
4215
|
+
* TypeUtil.isNegativeInteger(-1); // true
|
|
4216
|
+
* TypeUtil.isNegativeInteger(0); // false
|
|
4217
|
+
* ```
|
|
3854
4218
|
*/
|
|
3855
4219
|
static isNegativeInteger(value: unknown, checkSafe?: boolean): value is number;
|
|
3856
4220
|
/**
|
|
@@ -3858,6 +4222,11 @@ declare class TypeUtil {
|
|
|
3858
4222
|
* - 排除 `NaN`
|
|
3859
4223
|
*
|
|
3860
4224
|
* @param value 待检查值
|
|
4225
|
+
* @example
|
|
4226
|
+
* ```ts
|
|
4227
|
+
* TypeUtil.isInfinity(Infinity); // true
|
|
4228
|
+
* TypeUtil.isInfinity(1); // false
|
|
4229
|
+
* ```
|
|
3861
4230
|
*/
|
|
3862
4231
|
static isInfinity(value: unknown): value is number;
|
|
3863
4232
|
/**
|
|
@@ -3865,66 +4234,111 @@ declare class TypeUtil {
|
|
|
3865
4234
|
* - 排除 `NaN`
|
|
3866
4235
|
*
|
|
3867
4236
|
* @param value 待检查值
|
|
4237
|
+
* @example
|
|
4238
|
+
* ```ts
|
|
4239
|
+
* TypeUtil.isInfinityLike("Infinity"); // true
|
|
4240
|
+
* TypeUtil.isInfinityLike("123"); // false
|
|
4241
|
+
* ```
|
|
3868
4242
|
*/
|
|
3869
4243
|
static isInfinityLike(value: unknown): boolean;
|
|
3870
4244
|
/**
|
|
3871
4245
|
* 检查 value 是否为 Boolean
|
|
3872
4246
|
* @param value 待检查值
|
|
3873
4247
|
* @returns 是否为 Boolean
|
|
4248
|
+
* @example
|
|
4249
|
+
* ```ts
|
|
4250
|
+
* TypeUtil.isBoolean(false); // true
|
|
4251
|
+
* ```
|
|
3874
4252
|
*/
|
|
3875
4253
|
static isBoolean(value: unknown): value is boolean;
|
|
3876
4254
|
/**
|
|
3877
4255
|
* 检查 value 是否为 BigInt
|
|
3878
4256
|
* @param value 待检查值
|
|
3879
4257
|
* @returns 是否为 BigInt
|
|
4258
|
+
* @example
|
|
4259
|
+
* ```ts
|
|
4260
|
+
* TypeUtil.isBigInt(1n); // true
|
|
4261
|
+
* ```
|
|
3880
4262
|
*/
|
|
3881
4263
|
static isBigInt(value: unknown): value is bigint;
|
|
3882
4264
|
/**
|
|
3883
4265
|
* 检查 value 是否为 Symbol
|
|
3884
4266
|
* @param value 待检查值
|
|
3885
4267
|
* @returns 是否为 Symbol
|
|
4268
|
+
* @example
|
|
4269
|
+
* ```ts
|
|
4270
|
+
* TypeUtil.isSymbol(Symbol("a")); // true
|
|
4271
|
+
* ```
|
|
3886
4272
|
*/
|
|
3887
4273
|
static isSymbol(value: unknown): value is symbol;
|
|
3888
4274
|
/**
|
|
3889
4275
|
* 检查 value 是否为 undefined
|
|
3890
4276
|
* @param value 待检查值
|
|
3891
4277
|
* @returns 是否为 undefined
|
|
4278
|
+
* @example
|
|
4279
|
+
* ```ts
|
|
4280
|
+
* TypeUtil.isUndefined(undefined); // true
|
|
4281
|
+
* ```
|
|
3892
4282
|
*/
|
|
3893
4283
|
static isUndefined(value: unknown): value is undefined;
|
|
3894
4284
|
/**
|
|
3895
4285
|
* 检查 value 是否为 null
|
|
3896
4286
|
* @param value 待检查值
|
|
3897
4287
|
* @returns 是否为 null
|
|
4288
|
+
* @example
|
|
4289
|
+
* ```ts
|
|
4290
|
+
* TypeUtil.isNull(null); // true
|
|
4291
|
+
* ```
|
|
3898
4292
|
*/
|
|
3899
4293
|
static isNull(value: unknown): value is null;
|
|
3900
4294
|
/**
|
|
3901
4295
|
* 检查 value 是否为 Function
|
|
3902
4296
|
* @param value 待检查值
|
|
3903
4297
|
* @returns 是否为 Function
|
|
4298
|
+
* @example
|
|
4299
|
+
* ```ts
|
|
4300
|
+
* TypeUtil.isFunction(() => {}); // true
|
|
4301
|
+
* ```
|
|
3904
4302
|
*/
|
|
3905
4303
|
static isFunction(value: unknown): value is AnyFunction;
|
|
3906
4304
|
/**
|
|
3907
4305
|
* 检查 value 是否为 AsyncFunction
|
|
3908
4306
|
* @param value 待检查值
|
|
3909
4307
|
* @returns 是否为 AsyncFunction
|
|
4308
|
+
* @example
|
|
4309
|
+
* ```ts
|
|
4310
|
+
* TypeUtil.isAsyncFunction(async () => {}); // true
|
|
4311
|
+
* ```
|
|
3910
4312
|
*/
|
|
3911
4313
|
static isAsyncFunction(value: unknown): value is AnyAsyncFunction;
|
|
3912
4314
|
/**
|
|
3913
4315
|
* 检查 value 是否为 GeneratorFunction
|
|
3914
4316
|
* @param value 待检查值
|
|
3915
4317
|
* @returns 是否为 GeneratorFunction
|
|
4318
|
+
* @example
|
|
4319
|
+
* ```ts
|
|
4320
|
+
* TypeUtil.isGeneratorFunction(function * a () {}); // true
|
|
4321
|
+
* ```
|
|
3916
4322
|
*/
|
|
3917
4323
|
static isGeneratorFunction(value: unknown): value is AnyGeneratorFunction;
|
|
3918
4324
|
/**
|
|
3919
4325
|
* 检查 value 是否为 AsyncGeneratorFunction
|
|
3920
4326
|
* @param value 待检查值
|
|
3921
4327
|
* @returns 是否为 AsyncGeneratorFunction
|
|
4328
|
+
* @example
|
|
4329
|
+
* ```ts
|
|
4330
|
+
* TypeUtil.isAsyncGeneratorFunction(async function * a () {}); // true
|
|
4331
|
+
* ```
|
|
3922
4332
|
*/
|
|
3923
4333
|
static isAsyncGeneratorFunction(value: unknown): value is AnyAsyncGeneratorFunction;
|
|
3924
4334
|
/**
|
|
3925
4335
|
* 检查 value 是否为 Promise
|
|
3926
4336
|
* @param value 待检查值
|
|
3927
4337
|
* @returns 是否为 Promise
|
|
4338
|
+
* @example
|
|
4339
|
+
* ```ts
|
|
4340
|
+
* TypeUtil.isPromise(Promise.resolve(1)); // true
|
|
4341
|
+
* ```
|
|
3928
4342
|
*/
|
|
3929
4343
|
static isPromise(value: unknown): value is Promise<unknown>;
|
|
3930
4344
|
/**
|
|
@@ -3932,6 +4346,10 @@ declare class TypeUtil {
|
|
|
3932
4346
|
* - 可识别拥有 then 方法的非 Promise 对象
|
|
3933
4347
|
* @param value 待检查值
|
|
3934
4348
|
* @returns 是否为 PromiseLike
|
|
4349
|
+
* @example
|
|
4350
|
+
* ```ts
|
|
4351
|
+
* TypeUtil.isPromiseLike({ then: () => {} }); // true
|
|
4352
|
+
* ```
|
|
3935
4353
|
*/
|
|
3936
4354
|
static isPromiseLike(value: unknown): value is PromiseLike<unknown>;
|
|
3937
4355
|
/**
|
|
@@ -3962,6 +4380,11 @@ declare class TypeUtil {
|
|
|
3962
4380
|
*
|
|
3963
4381
|
* @param enumeration 待检查值
|
|
3964
4382
|
* @returns [是否为有效的枚举, 是否为双向枚举]
|
|
4383
|
+
* @example
|
|
4384
|
+
* ```ts
|
|
4385
|
+
* enum A { X, Y }
|
|
4386
|
+
* TypeUtil.isEnumeration(A); // [true, true]
|
|
4387
|
+
* ```
|
|
3965
4388
|
*/
|
|
3966
4389
|
static isEnumeration(enumeration: PlainObject): [boolean, boolean];
|
|
3967
4390
|
/**
|
|
@@ -4003,36 +4426,60 @@ declare class TypeUtil {
|
|
|
4003
4426
|
* 检查 value 是否为 Map
|
|
4004
4427
|
* @param value 待检查值
|
|
4005
4428
|
* @returns 是否为 Map
|
|
4429
|
+
* @example
|
|
4430
|
+
* ```ts
|
|
4431
|
+
* TypeUtil.isMap(new Map()); // true
|
|
4432
|
+
* ```
|
|
4006
4433
|
*/
|
|
4007
4434
|
static isMap(value: unknown): value is Map<unknown, unknown>;
|
|
4008
4435
|
/**
|
|
4009
4436
|
* 检查 value 是否为 WeakMap
|
|
4010
4437
|
* @param value 待检查值
|
|
4011
4438
|
* @returns 是否为 WeakMap
|
|
4439
|
+
* @example
|
|
4440
|
+
* ```ts
|
|
4441
|
+
* TypeUtil.isWeakMap(new WeakMap()); // true
|
|
4442
|
+
* ```
|
|
4012
4443
|
*/
|
|
4013
4444
|
static isWeakMap(value: unknown): value is WeakMap<AnyObject, unknown>;
|
|
4014
4445
|
/**
|
|
4015
4446
|
* 检查 value 是否为 Set
|
|
4016
4447
|
* @param value 待检查值
|
|
4017
4448
|
* @returns 是否为 Set
|
|
4449
|
+
* @example
|
|
4450
|
+
* ```ts
|
|
4451
|
+
* TypeUtil.isSet(new Set()); // true
|
|
4452
|
+
* ```
|
|
4018
4453
|
*/
|
|
4019
4454
|
static isSet(value: unknown): value is Set<unknown>;
|
|
4020
4455
|
/**
|
|
4021
4456
|
* 检查 value 是否为 WeakSet
|
|
4022
4457
|
* @param value 待检查值
|
|
4023
4458
|
* @returns 是否为 WeakSet
|
|
4459
|
+
* @example
|
|
4460
|
+
* ```ts
|
|
4461
|
+
* TypeUtil.isWeakSet(new WeakSet()); // true
|
|
4462
|
+
* ```
|
|
4024
4463
|
*/
|
|
4025
4464
|
static isWeakSet(value: unknown): value is WeakSet<AnyObject>;
|
|
4026
4465
|
/**
|
|
4027
4466
|
* 检查 value 是否为 Blob
|
|
4028
4467
|
* @param value 待检查值
|
|
4029
4468
|
* @returns 是否为 Blob
|
|
4469
|
+
* @example
|
|
4470
|
+
* ```ts
|
|
4471
|
+
* TypeUtil.isBlob(new Blob(["a"])); // true
|
|
4472
|
+
* ```
|
|
4030
4473
|
*/
|
|
4031
4474
|
static isBlob(value: unknown): value is Blob;
|
|
4032
4475
|
/**
|
|
4033
4476
|
* 检查 value 是否为 File
|
|
4034
4477
|
* @param value 待检查值
|
|
4035
4478
|
* @returns 是否为 File
|
|
4479
|
+
* @example
|
|
4480
|
+
* ```ts
|
|
4481
|
+
* TypeUtil.isFile(new File(["a"], "a.txt")); // true
|
|
4482
|
+
* ```
|
|
4036
4483
|
*/
|
|
4037
4484
|
static isFile(value: unknown): value is File;
|
|
4038
4485
|
/**
|
|
@@ -4044,18 +4491,30 @@ declare class TypeUtil {
|
|
|
4044
4491
|
*
|
|
4045
4492
|
* @param value 待检查值
|
|
4046
4493
|
* @returns 是否为 ReadableStream
|
|
4494
|
+
* @example
|
|
4495
|
+
* ```ts
|
|
4496
|
+
* TypeUtil.isReadableStream(new ReadableStream()); // true
|
|
4497
|
+
* ```
|
|
4047
4498
|
*/
|
|
4048
4499
|
static isReadableStream(value: unknown): value is ReadableStream;
|
|
4049
4500
|
/**
|
|
4050
4501
|
* 检查 value 是否为 Window
|
|
4051
4502
|
* @param value 待检查值
|
|
4052
4503
|
* @returns 是否为 Window
|
|
4504
|
+
* @example
|
|
4505
|
+
* ```ts
|
|
4506
|
+
* TypeUtil.isWindow(window); // true
|
|
4507
|
+
* ```
|
|
4053
4508
|
*/
|
|
4054
4509
|
static isWindow(value: unknown): value is Window;
|
|
4055
4510
|
/**
|
|
4056
4511
|
* 检查 value 是否为 HTMLIFrameElement
|
|
4057
4512
|
* @param value 待检查值
|
|
4058
4513
|
* @returns 是否为 HTMLIFrameElement
|
|
4514
|
+
* @example
|
|
4515
|
+
* ```ts
|
|
4516
|
+
* TypeUtil.isIframe(document.createElement("iframe")); // true
|
|
4517
|
+
* ```
|
|
4059
4518
|
*/
|
|
4060
4519
|
static isIframe(value: unknown): value is HTMLIFrameElement;
|
|
4061
4520
|
/**
|
|
@@ -4081,36 +4540,60 @@ declare class TypeUtil {
|
|
|
4081
4540
|
* 检查 value 是否为 Error 对象
|
|
4082
4541
|
* @param value 待检查值
|
|
4083
4542
|
* @returns 是否为 Error
|
|
4543
|
+
* @example
|
|
4544
|
+
* ```ts
|
|
4545
|
+
* TypeUtil.isError(new Error("x")); // true
|
|
4546
|
+
* ```
|
|
4084
4547
|
*/
|
|
4085
4548
|
static isError(value: unknown): value is Error;
|
|
4086
4549
|
/**
|
|
4087
4550
|
* 检查 value 是否为 RegExp
|
|
4088
4551
|
* @param value 待检查值
|
|
4089
4552
|
* @returns 是否为 RegExp
|
|
4553
|
+
* @example
|
|
4554
|
+
* ```ts
|
|
4555
|
+
* TypeUtil.isRegExp(/a/); // true
|
|
4556
|
+
* ```
|
|
4090
4557
|
*/
|
|
4091
4558
|
static isRegExp(value: unknown): value is RegExp;
|
|
4092
4559
|
/**
|
|
4093
4560
|
* 检查 value 是否为 WebSocket
|
|
4094
4561
|
* @param value 待检查值
|
|
4095
4562
|
* @returns 是否为 WebSocket
|
|
4563
|
+
* @example
|
|
4564
|
+
* ```ts
|
|
4565
|
+
* TypeUtil.isWebSocket(new WebSocket("wss://echo.websocket.events")); // true
|
|
4566
|
+
* ```
|
|
4096
4567
|
*/
|
|
4097
4568
|
static isWebSocket(value: unknown): value is WebSocket;
|
|
4098
4569
|
/**
|
|
4099
4570
|
* 检查 value 是否为 URLSearchParams
|
|
4100
4571
|
* @param value 待检查值
|
|
4101
4572
|
* @returns 是否为 URLSearchParams
|
|
4573
|
+
* @example
|
|
4574
|
+
* ```ts
|
|
4575
|
+
* TypeUtil.isURLSearchParams(new URLSearchParams("a=1")); // true
|
|
4576
|
+
* ```
|
|
4102
4577
|
*/
|
|
4103
4578
|
static isURLSearchParams(value: unknown): value is URLSearchParams;
|
|
4104
4579
|
/**
|
|
4105
4580
|
* 检查 value 是否为 AbortSignal
|
|
4106
4581
|
* @param value 待检查值
|
|
4107
4582
|
* @returns 是否为 AbortSignal
|
|
4583
|
+
* @example
|
|
4584
|
+
* ```ts
|
|
4585
|
+
* TypeUtil.isAbortSignal(new AbortController().signal); // true
|
|
4586
|
+
* ```
|
|
4108
4587
|
*/
|
|
4109
4588
|
static isAbortSignal(value: unknown): value is AbortSignal;
|
|
4110
4589
|
/**
|
|
4111
4590
|
* 检查 value 是否为可迭代对象 (Iterable)
|
|
4112
4591
|
* @param value 待检查值
|
|
4113
4592
|
* @returns 是否为 Iterable
|
|
4593
|
+
* @example
|
|
4594
|
+
* ```ts
|
|
4595
|
+
* TypeUtil.isIterable([1, 2]); // true
|
|
4596
|
+
* ```
|
|
4114
4597
|
*/
|
|
4115
4598
|
static isIterable(value: unknown): value is {
|
|
4116
4599
|
[Symbol.iterator]: () => Iterator<unknown>;
|
|
@@ -4119,8 +4602,24 @@ declare class TypeUtil {
|
|
|
4119
4602
|
* 检查 value 是否为 Falsy 值 (false, 0, "", null, undefined, NaN)
|
|
4120
4603
|
* @param value 待检查值
|
|
4121
4604
|
* @returns 是否为 Falsy
|
|
4605
|
+
* @example
|
|
4606
|
+
* ```ts
|
|
4607
|
+
* TypeUtil.isFalsy(0); // true
|
|
4608
|
+
* ```
|
|
4122
4609
|
*/
|
|
4123
4610
|
static isFalsy(value: unknown): value is false | 0 | "" | null | undefined;
|
|
4611
|
+
/**
|
|
4612
|
+
* 检查 value 是否为 FalsyLike 值
|
|
4613
|
+
* - 包含字符串形式的 `"null"`、`"undefined"`、`"false"`、`"0"` 等
|
|
4614
|
+
*
|
|
4615
|
+
* @param value 待检查值
|
|
4616
|
+
* @returns 是否为 FalsyLike
|
|
4617
|
+
* @example
|
|
4618
|
+
* ```ts
|
|
4619
|
+
* TypeUtil.isFalsyLike("false"); // true
|
|
4620
|
+
* TypeUtil.isFalsyLike("hello"); // false
|
|
4621
|
+
* ```
|
|
4622
|
+
*/
|
|
4124
4623
|
static isFalsyLike(value: unknown): boolean;
|
|
4125
4624
|
}
|
|
4126
4625
|
//#endregion
|
|
@@ -4132,162 +4631,290 @@ declare class ValidateUtil {
|
|
|
4132
4631
|
static _phone: RegExp;
|
|
4133
4632
|
/**
|
|
4134
4633
|
* 验证是否为手机号码
|
|
4634
|
+
* @example
|
|
4635
|
+
* ```ts
|
|
4636
|
+
* ValidateUtil.isPhone("13800138000"); // true
|
|
4637
|
+
* ```
|
|
4135
4638
|
*/
|
|
4136
4639
|
static isPhone(input: string): boolean;
|
|
4137
4640
|
static _telephone: RegExp;
|
|
4138
4641
|
/**
|
|
4139
4642
|
* 验证是否为固定电话
|
|
4643
|
+
* @example
|
|
4644
|
+
* ```ts
|
|
4645
|
+
* ValidateUtil.isTelephone("010-12345678"); // true
|
|
4646
|
+
* ```
|
|
4140
4647
|
*/
|
|
4141
4648
|
static isTelephone(input: string): boolean;
|
|
4142
4649
|
static _IMEI: RegExp;
|
|
4143
4650
|
/**
|
|
4144
4651
|
* 验证是否为移动设备识别码
|
|
4652
|
+
* @example
|
|
4653
|
+
* ```ts
|
|
4654
|
+
* ValidateUtil.isIMEI("490154203237518"); // true
|
|
4655
|
+
* ```
|
|
4145
4656
|
*/
|
|
4146
4657
|
static isIMEI(input: string): boolean;
|
|
4147
4658
|
static _email: RegExp;
|
|
4148
4659
|
/**
|
|
4149
4660
|
* 验证是否为电子邮箱
|
|
4661
|
+
* @example
|
|
4662
|
+
* ```ts
|
|
4663
|
+
* ValidateUtil.isEmail("dev@example.com"); // true
|
|
4664
|
+
* ```
|
|
4150
4665
|
*/
|
|
4151
4666
|
static isEmail(input: string): boolean;
|
|
4152
4667
|
static _link: RegExp;
|
|
4153
4668
|
/**
|
|
4154
4669
|
* 验证是否为 http(s) 链接
|
|
4670
|
+
* @example
|
|
4671
|
+
* ```ts
|
|
4672
|
+
* ValidateUtil.isHttpLink("https://example.com/path"); // true
|
|
4673
|
+
* ```
|
|
4155
4674
|
*/
|
|
4156
4675
|
static isHttpLink(input: string): boolean;
|
|
4157
4676
|
static _portLink: RegExp;
|
|
4158
4677
|
/**
|
|
4159
4678
|
* 验证是否为端口号链接
|
|
4679
|
+
* @example
|
|
4680
|
+
* ```ts
|
|
4681
|
+
* ValidateUtil.isPortLink("http://example.com:8080"); // true
|
|
4682
|
+
* ```
|
|
4160
4683
|
*/
|
|
4161
4684
|
static isPortLink(input: string): boolean;
|
|
4162
4685
|
static _thunderLink: RegExp;
|
|
4163
4686
|
/**
|
|
4164
4687
|
* 验证是否为迅雷链接
|
|
4688
|
+
* @example
|
|
4689
|
+
* ```ts
|
|
4690
|
+
* ValidateUtil.isThunderLink("thunder://QUFodHRwOi8vZXhhbXBsZS5jb20vZmlsZQ=="); // true
|
|
4691
|
+
* ```
|
|
4165
4692
|
*/
|
|
4166
4693
|
static isThunderLink(input: string): boolean;
|
|
4167
4694
|
static _uscc: RegExp;
|
|
4168
4695
|
/**
|
|
4169
4696
|
* 验证是否为统一社会信用代码
|
|
4697
|
+
* @example
|
|
4698
|
+
* ```ts
|
|
4699
|
+
* ValidateUtil.isUSCC("91350100M000100Y43"); // true
|
|
4700
|
+
* ```
|
|
4170
4701
|
*/
|
|
4171
4702
|
static isUSCC(input: string): boolean;
|
|
4172
4703
|
static _usccs: RegExp;
|
|
4173
4704
|
/**
|
|
4174
4705
|
* 验证是否为统一社会信用代码 - 15位/18位/20位数字/字母
|
|
4706
|
+
* @example
|
|
4707
|
+
* ```ts
|
|
4708
|
+
* ValidateUtil.isUSCCS("91350100M000100Y43"); // true
|
|
4709
|
+
* ```
|
|
4175
4710
|
*/
|
|
4176
4711
|
static isUSCCS(input: string): boolean;
|
|
4177
4712
|
static _dirPathWindows: RegExp;
|
|
4178
4713
|
/**
|
|
4179
4714
|
* 验证是否为 Windows 系统文件夹路径
|
|
4715
|
+
* @example
|
|
4716
|
+
* ```ts
|
|
4717
|
+
* ValidateUtil.isDirPathWindows("C:\\Users\\pawover\\"); // true
|
|
4718
|
+
* ```
|
|
4180
4719
|
*/
|
|
4181
4720
|
static isDirPathWindows(input: string): boolean;
|
|
4182
4721
|
static _filePathWindows: RegExp;
|
|
4183
4722
|
/**
|
|
4184
4723
|
* 验证是否为 Windows 系统文件路径
|
|
4724
|
+
* @example
|
|
4725
|
+
* ```ts
|
|
4726
|
+
* ValidateUtil.isFilePathWindows("C:\\Users\\pawover\\a.txt"); // true
|
|
4727
|
+
* ```
|
|
4185
4728
|
*/
|
|
4186
4729
|
static isFilePathWindows(input: string): boolean;
|
|
4187
4730
|
static _dirPathLinux: RegExp;
|
|
4188
4731
|
/**
|
|
4189
4732
|
* 验证是否为 Linux 系统文件夹路径
|
|
4733
|
+
* @example
|
|
4734
|
+
* ```ts
|
|
4735
|
+
* ValidateUtil.isDirPathLinux("/usr/local/"); // true
|
|
4736
|
+
* ```
|
|
4190
4737
|
*/
|
|
4191
4738
|
static isDirPathLinux(input: string): boolean;
|
|
4192
4739
|
static _filePathLinux: RegExp;
|
|
4193
4740
|
/**
|
|
4194
4741
|
* 验证是否为 Linux 系统文件路径
|
|
4742
|
+
* @example
|
|
4743
|
+
* ```ts
|
|
4744
|
+
* ValidateUtil.isFilePathLinux("/usr/local/bin/node"); // true
|
|
4745
|
+
* ```
|
|
4195
4746
|
*/
|
|
4196
4747
|
static isFilePathLinux(input: string): boolean;
|
|
4197
4748
|
static _EVCarNumber: RegExp;
|
|
4198
4749
|
/**
|
|
4199
4750
|
* 验证是否为新能源车牌号
|
|
4751
|
+
* @example
|
|
4752
|
+
* ```ts
|
|
4753
|
+
* ValidateUtil.isEVCarNumber("粤AD12345"); // true
|
|
4754
|
+
* ```
|
|
4200
4755
|
*/
|
|
4201
4756
|
static isEVCarNumber(input: string): boolean;
|
|
4202
4757
|
static _GVCarNumber: RegExp;
|
|
4203
4758
|
/**
|
|
4204
4759
|
* 验证是否为燃油车车牌号
|
|
4760
|
+
* @example
|
|
4761
|
+
* ```ts
|
|
4762
|
+
* ValidateUtil.isGVCarNumber("粤B12345"); // true
|
|
4763
|
+
* ```
|
|
4205
4764
|
*/
|
|
4206
4765
|
static isGVCarNumber(input: string): boolean;
|
|
4207
4766
|
static _chineseName: RegExp;
|
|
4208
4767
|
/**
|
|
4209
4768
|
* 验证是否为中文姓名
|
|
4769
|
+
* @example
|
|
4770
|
+
* ```ts
|
|
4771
|
+
* ValidateUtil.isChineseName("张三"); // true
|
|
4772
|
+
* ```
|
|
4210
4773
|
*/
|
|
4211
4774
|
static isChineseName(input: string): boolean;
|
|
4212
4775
|
static _chineseId: RegExp;
|
|
4213
4776
|
/**
|
|
4214
4777
|
* 验证是否为中国身份证号
|
|
4778
|
+
* @example
|
|
4779
|
+
* ```ts
|
|
4780
|
+
* ValidateUtil.isChineseID("11010519491231002X"); // true
|
|
4781
|
+
* ```
|
|
4215
4782
|
*/
|
|
4216
4783
|
static isChineseID(input: string): boolean;
|
|
4217
4784
|
static _chineseProvince: RegExp;
|
|
4218
4785
|
/**
|
|
4219
4786
|
* 验证是否为中国省份
|
|
4787
|
+
* @example
|
|
4788
|
+
* ```ts
|
|
4789
|
+
* ValidateUtil.isChineseProvince("浙江"); // true
|
|
4790
|
+
* ```
|
|
4220
4791
|
*/
|
|
4221
4792
|
static isChineseProvince(input: string): boolean;
|
|
4222
4793
|
static _chineseNation: RegExp;
|
|
4223
4794
|
/**
|
|
4224
4795
|
* 验证是否为中华民族
|
|
4796
|
+
* @example
|
|
4797
|
+
* ```ts
|
|
4798
|
+
* ValidateUtil.isChineseNation("汉族"); // true
|
|
4799
|
+
* ```
|
|
4225
4800
|
*/
|
|
4226
4801
|
static isChineseNation(input: string): boolean;
|
|
4227
4802
|
static _letter: RegExp;
|
|
4228
4803
|
/**
|
|
4229
4804
|
* 验证是否只包含字母
|
|
4805
|
+
* @example
|
|
4806
|
+
* ```ts
|
|
4807
|
+
* ValidateUtil.isLetter("abcDEF"); // true
|
|
4808
|
+
* ```
|
|
4230
4809
|
*/
|
|
4231
4810
|
static isLetter(input: string): boolean;
|
|
4232
4811
|
static _letterLowercase: RegExp;
|
|
4233
4812
|
/**
|
|
4234
4813
|
* 验证是否只包含小写字母
|
|
4814
|
+
* @example
|
|
4815
|
+
* ```ts
|
|
4816
|
+
* ValidateUtil.isLetterLowercase("abc"); // true
|
|
4817
|
+
* ```
|
|
4235
4818
|
*/
|
|
4236
4819
|
static isLetterLowercase(input: string): boolean;
|
|
4237
4820
|
static _letterUppercase: RegExp;
|
|
4238
4821
|
/**
|
|
4239
4822
|
* 验证是否只包含大写字母
|
|
4823
|
+
* @example
|
|
4824
|
+
* ```ts
|
|
4825
|
+
* ValidateUtil.isLetterUppercase("ABC"); // true
|
|
4826
|
+
* ```
|
|
4240
4827
|
*/
|
|
4241
4828
|
static isLetterUppercase(input: string): boolean;
|
|
4242
4829
|
static _letterOmit: RegExp;
|
|
4243
4830
|
/**
|
|
4244
4831
|
* 验证是否不包含字母
|
|
4832
|
+
* @example
|
|
4833
|
+
* ```ts
|
|
4834
|
+
* ValidateUtil.isLetterOmit("123_-"); // true
|
|
4835
|
+
* ```
|
|
4245
4836
|
*/
|
|
4246
4837
|
static isLetterOmit(input: string): boolean;
|
|
4247
4838
|
static _LetterAndNumber: RegExp;
|
|
4248
4839
|
/**
|
|
4249
4840
|
* 验证是否为数字和字母组合
|
|
4841
|
+
* @example
|
|
4842
|
+
* ```ts
|
|
4843
|
+
* ValidateUtil.isLetterAndNumber("A1B2"); // true
|
|
4844
|
+
* ```
|
|
4250
4845
|
*/
|
|
4251
4846
|
static isLetterAndNumber(input: string): boolean;
|
|
4252
4847
|
static _signedFloat: RegExp;
|
|
4253
4848
|
/**
|
|
4254
4849
|
* 验证是否为有符号浮点数
|
|
4850
|
+
* @example
|
|
4851
|
+
* ```ts
|
|
4852
|
+
* ValidateUtil.isSignedFloat("-12.34"); // true
|
|
4853
|
+
* ```
|
|
4255
4854
|
*/
|
|
4256
4855
|
static isSignedFloat(input: string): boolean;
|
|
4257
4856
|
static _unsignedFloat: RegExp;
|
|
4258
4857
|
/**
|
|
4259
4858
|
* 验证是否为无符号浮点数
|
|
4859
|
+
* @example
|
|
4860
|
+
* ```ts
|
|
4861
|
+
* ValidateUtil.isUnsignedFloat("12.34"); // true
|
|
4862
|
+
* ```
|
|
4260
4863
|
*/
|
|
4261
4864
|
static isUnsignedFloat(input: string): boolean;
|
|
4262
4865
|
static _signedInteger: RegExp;
|
|
4263
4866
|
/**
|
|
4264
4867
|
* 验证是否为有符号整数
|
|
4868
|
+
* @example
|
|
4869
|
+
* ```ts
|
|
4870
|
+
* ValidateUtil.isSignedInteger("-12"); // true
|
|
4871
|
+
* ```
|
|
4265
4872
|
*/
|
|
4266
4873
|
static isSignedInteger(input: string): boolean;
|
|
4267
4874
|
static _unsignedInteger: RegExp;
|
|
4268
4875
|
/**
|
|
4269
4876
|
* 验证是否为无符号整数
|
|
4877
|
+
* @example
|
|
4878
|
+
* ```ts
|
|
4879
|
+
* ValidateUtil.isUnsignedInteger("12"); // true
|
|
4880
|
+
* ```
|
|
4270
4881
|
*/
|
|
4271
4882
|
static isUnsignedInteger(input: string): boolean;
|
|
4272
4883
|
static _spaceInclude: RegExp;
|
|
4273
4884
|
/**
|
|
4274
4885
|
* 验证是否包含空格
|
|
4886
|
+
* @example
|
|
4887
|
+
* ```ts
|
|
4888
|
+
* ValidateUtil.isSpaceInclude("a b"); // true
|
|
4889
|
+
* ```
|
|
4275
4890
|
*/
|
|
4276
4891
|
static isSpaceInclude(input: string): boolean;
|
|
4277
4892
|
static _spaceStart: RegExp;
|
|
4278
4893
|
/**
|
|
4279
4894
|
* 验证是否以空格开头
|
|
4895
|
+
* @example
|
|
4896
|
+
* ```ts
|
|
4897
|
+
* ValidateUtil.isSpaceStart(" abc"); // true
|
|
4898
|
+
* ```
|
|
4280
4899
|
*/
|
|
4281
4900
|
static isSpaceStart(input: string): boolean;
|
|
4282
4901
|
static _spaceEnd: RegExp;
|
|
4283
4902
|
/**
|
|
4284
4903
|
* 验证是否以空格结尾
|
|
4904
|
+
* @example
|
|
4905
|
+
* ```ts
|
|
4906
|
+
* ValidateUtil.isSpaceEnd("abc "); // true
|
|
4907
|
+
* ```
|
|
4285
4908
|
*/
|
|
4286
4909
|
static isSpaceEnd(input: string): boolean;
|
|
4287
4910
|
/**
|
|
4288
4911
|
* 验证是否以空格开头或结尾
|
|
4912
|
+
* @example
|
|
4913
|
+
* ```ts
|
|
4914
|
+
* ValidateUtil.isSpaceStartOrEnd(" abc"); // true
|
|
4915
|
+
* ```
|
|
4289
4916
|
*/
|
|
4290
4917
|
static isSpaceStartOrEnd(input: string): boolean;
|
|
4291
4918
|
}
|
|
4292
4919
|
//#endregion
|
|
4293
|
-
export { ArrayUtil, DateTimeUtil, EnvUtil, FunctionUtil, MimeUtil, NumberUtil, ObjectUtil, StringUtil, THEME_MODE_TYPE, THEME_TYPE, ThemeUtil, TreeUtil, TypeUtil, ValidateUtil };
|
|
4920
|
+
export { ArrayUtil, DateTimeUtil, EnvUtil, FunctionUtil, MimeUtil, NumberUtil, ObjectUtil, StringUtil, type THEME_MODE_TYPE, type THEME_TYPE, ThemeUtil, TreeUtil, TypeUtil, ValidateUtil };
|