@pawover/kit 0.0.1 → 0.1.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.
@@ -1,4 +1,4 @@
1
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
1
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
2
2
  function _typeof(o) {
3
3
  "@babel/helpers - typeof";
4
4
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -8,7 +8,7 @@ function _typeof(o) {
8
8
  }, _typeof(o);
9
9
  }
10
10
  //#endregion
11
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
11
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
12
12
  function toPrimitive(t, r) {
13
13
  if ("object" != _typeof(t) || !t) return t;
14
14
  var e = t[Symbol.toPrimitive];
@@ -20,13 +20,13 @@ function toPrimitive(t, r) {
20
20
  return ("string" === r ? String : Number)(t);
21
21
  }
22
22
  //#endregion
23
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
23
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
24
24
  function toPropertyKey(t) {
25
25
  var i = toPrimitive(t, "string");
26
26
  return "symbol" == _typeof(i) ? i : i + "";
27
27
  }
28
28
  //#endregion
29
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
29
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
30
30
  function _defineProperty(e, r, t) {
31
31
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
32
32
  value: t,
@@ -76,9 +76,10 @@ var TypeUtil = class {
76
76
  }
77
77
  /**
78
78
  * 检查 value 是否为 number 类型
79
+ * - 默认会调用 `TypeUtil.isNaN`(内部基于 `Number.isNaN`)过滤掉 `NaN`
79
80
  *
80
81
  * @param value 待检查值
81
- * @param checkNaN 是否排除 `NaN`,默认为 `true`
82
+ * @param checkNaN 是否检查 `NaN`,默认为 `true`
82
83
  * @returns 是否为 number
83
84
  * @example
84
85
  * ```ts
@@ -92,9 +93,15 @@ var TypeUtil = class {
92
93
  }
93
94
  /**
94
95
  * 检查 value 是否为 NaN
96
+ * - 禁止使用全局 `isNaN`,其会先进行隐式数字转换,可能导致误判(例如 `isNaN("foo") === true`)
97
+ * - 使用 `Number.isNaN` 仅在值本身就是 `NaN` 时返回 `true`,语义更严格且更安全
95
98
  *
96
99
  * @param value 待检查值
97
100
  * @returns 是否为 NaN
101
+ * @example
102
+ * ```ts
103
+ * TypeUtil.isNaN(NaN); // true
104
+ * ```
98
105
  */
99
106
  static isNaN(value) {
100
107
  return Number.isNaN(value);
@@ -105,6 +112,11 @@ var TypeUtil = class {
105
112
  * @param value 待检查值
106
113
  * @param checkSafe 是否附加安全整数检查
107
114
  * @returns 是否为整数
115
+ * @example
116
+ * ```ts
117
+ * TypeUtil.isInteger(1); // true
118
+ * TypeUtil.isInteger(1.1); // false
119
+ * ```
108
120
  */
109
121
  static isInteger(value, checkSafe = true) {
110
122
  const check = Number.isInteger(value);
@@ -116,6 +128,11 @@ var TypeUtil = class {
116
128
  *
117
129
  * @param value 待检查值
118
130
  * @param checkSafe 是否附加安全整数检查
131
+ * @example
132
+ * ```ts
133
+ * TypeUtil.isPositiveInteger(1); // true
134
+ * TypeUtil.isPositiveInteger(0); // false
135
+ * ```
119
136
  */
120
137
  static isPositiveInteger(value, checkSafe = true) {
121
138
  return this.isInteger(value, checkSafe) && value > 0;
@@ -126,6 +143,11 @@ var TypeUtil = class {
126
143
  *
127
144
  * @param value 待检查值
128
145
  * @param checkSafe 是否附加安全整数检查
146
+ * @example
147
+ * ```ts
148
+ * TypeUtil.isNegativeInteger(-1); // true
149
+ * TypeUtil.isNegativeInteger(0); // false
150
+ * ```
129
151
  */
130
152
  static isNegativeInteger(value, checkSafe = true) {
131
153
  return this.isInteger(value, checkSafe) && value < 0;
@@ -135,6 +157,11 @@ var TypeUtil = class {
135
157
  * - 排除 `NaN`
136
158
  *
137
159
  * @param value 待检查值
160
+ * @example
161
+ * ```ts
162
+ * TypeUtil.isInfinity(Infinity); // true
163
+ * TypeUtil.isInfinity(1); // false
164
+ * ```
138
165
  */
139
166
  static isInfinity(value) {
140
167
  return this.isNumber(value) && (Number.POSITIVE_INFINITY === value || Number.NEGATIVE_INFINITY === value);
@@ -144,6 +171,11 @@ var TypeUtil = class {
144
171
  * - 排除 `NaN`
145
172
  *
146
173
  * @param value 待检查值
174
+ * @example
175
+ * ```ts
176
+ * TypeUtil.isInfinityLike("Infinity"); // true
177
+ * TypeUtil.isInfinityLike("123"); // false
178
+ * ```
147
179
  */
148
180
  static isInfinityLike(value) {
149
181
  const check = this.isInfinity(value);
@@ -162,6 +194,10 @@ var TypeUtil = class {
162
194
  * 检查 value 是否为 Boolean
163
195
  * @param value 待检查值
164
196
  * @returns 是否为 Boolean
197
+ * @example
198
+ * ```ts
199
+ * TypeUtil.isBoolean(false); // true
200
+ * ```
165
201
  */
166
202
  static isBoolean(value) {
167
203
  return typeof value === "boolean";
@@ -170,6 +206,10 @@ var TypeUtil = class {
170
206
  * 检查 value 是否为 BigInt
171
207
  * @param value 待检查值
172
208
  * @returns 是否为 BigInt
209
+ * @example
210
+ * ```ts
211
+ * TypeUtil.isBigInt(1n); // true
212
+ * ```
173
213
  */
174
214
  static isBigInt(value) {
175
215
  return typeof value === "bigint";
@@ -178,6 +218,10 @@ var TypeUtil = class {
178
218
  * 检查 value 是否为 Symbol
179
219
  * @param value 待检查值
180
220
  * @returns 是否为 Symbol
221
+ * @example
222
+ * ```ts
223
+ * TypeUtil.isSymbol(Symbol("a")); // true
224
+ * ```
181
225
  */
182
226
  static isSymbol(value) {
183
227
  return typeof value === "symbol";
@@ -186,6 +230,10 @@ var TypeUtil = class {
186
230
  * 检查 value 是否为 undefined
187
231
  * @param value 待检查值
188
232
  * @returns 是否为 undefined
233
+ * @example
234
+ * ```ts
235
+ * TypeUtil.isUndefined(undefined); // true
236
+ * ```
189
237
  */
190
238
  static isUndefined(value) {
191
239
  return typeof value === "undefined";
@@ -194,6 +242,10 @@ var TypeUtil = class {
194
242
  * 检查 value 是否为 null
195
243
  * @param value 待检查值
196
244
  * @returns 是否为 null
245
+ * @example
246
+ * ```ts
247
+ * TypeUtil.isNull(null); // true
248
+ * ```
197
249
  */
198
250
  static isNull(value) {
199
251
  return value === null;
@@ -202,6 +254,10 @@ var TypeUtil = class {
202
254
  * 检查 value 是否为 Function
203
255
  * @param value 待检查值
204
256
  * @returns 是否为 Function
257
+ * @example
258
+ * ```ts
259
+ * TypeUtil.isFunction(() => {}); // true
260
+ * ```
205
261
  */
206
262
  static isFunction(value) {
207
263
  return typeof value === "function";
@@ -210,6 +266,10 @@ var TypeUtil = class {
210
266
  * 检查 value 是否为 AsyncFunction
211
267
  * @param value 待检查值
212
268
  * @returns 是否为 AsyncFunction
269
+ * @example
270
+ * ```ts
271
+ * TypeUtil.isAsyncFunction(async () => {}); // true
272
+ * ```
213
273
  */
214
274
  static isAsyncFunction(value) {
215
275
  return this.isFunction(value) && this.getPrototypeString(value) === this.PROTOTYPE_TAGS.ASYNC_FUNCTION;
@@ -218,6 +278,10 @@ var TypeUtil = class {
218
278
  * 检查 value 是否为 GeneratorFunction
219
279
  * @param value 待检查值
220
280
  * @returns 是否为 GeneratorFunction
281
+ * @example
282
+ * ```ts
283
+ * TypeUtil.isGeneratorFunction(function * a () {}); // true
284
+ * ```
221
285
  */
222
286
  static isGeneratorFunction(value) {
223
287
  return this.isFunction(value) && this.getPrototypeString(value) === this.PROTOTYPE_TAGS.GENERATOR_FUNCTION;
@@ -226,6 +290,10 @@ var TypeUtil = class {
226
290
  * 检查 value 是否为 AsyncGeneratorFunction
227
291
  * @param value 待检查值
228
292
  * @returns 是否为 AsyncGeneratorFunction
293
+ * @example
294
+ * ```ts
295
+ * TypeUtil.isAsyncGeneratorFunction(async function * a () {}); // true
296
+ * ```
229
297
  */
230
298
  static isAsyncGeneratorFunction(value) {
231
299
  return this.isFunction(value) && this.getPrototypeString(value) === this.PROTOTYPE_TAGS.ASYNC_GENERATOR_FUNCTION;
@@ -234,6 +302,10 @@ var TypeUtil = class {
234
302
  * 检查 value 是否为 Promise
235
303
  * @param value 待检查值
236
304
  * @returns 是否为 Promise
305
+ * @example
306
+ * ```ts
307
+ * TypeUtil.isPromise(Promise.resolve(1)); // true
308
+ * ```
237
309
  */
238
310
  static isPromise(value) {
239
311
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.PROMISE;
@@ -243,6 +315,10 @@ var TypeUtil = class {
243
315
  * - 可识别拥有 then 方法的非 Promise 对象
244
316
  * @param value 待检查值
245
317
  * @returns 是否为 PromiseLike
318
+ * @example
319
+ * ```ts
320
+ * TypeUtil.isPromiseLike({ then: () => {} }); // true
321
+ * ```
246
322
  */
247
323
  static isPromiseLike(value) {
248
324
  return this.isPromise(value) || this.isObject(value, false) && this.isFunction(value["then"]);
@@ -278,6 +354,11 @@ var TypeUtil = class {
278
354
  *
279
355
  * @param enumeration 待检查值
280
356
  * @returns [是否为有效的枚举, 是否为双向枚举]
357
+ * @example
358
+ * ```ts
359
+ * enum A { X, Y }
360
+ * TypeUtil.isEnumeration(A); // [true, true]
361
+ * ```
281
362
  */
282
363
  static isEnumeration(enumeration) {
283
364
  if (typeof enumeration !== "object" || enumeration === null) return [false, false];
@@ -359,6 +440,10 @@ var TypeUtil = class {
359
440
  * 检查 value 是否为 Map
360
441
  * @param value 待检查值
361
442
  * @returns 是否为 Map
443
+ * @example
444
+ * ```ts
445
+ * TypeUtil.isMap(new Map()); // true
446
+ * ```
362
447
  */
363
448
  static isMap(value) {
364
449
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.MAP;
@@ -367,6 +452,10 @@ var TypeUtil = class {
367
452
  * 检查 value 是否为 WeakMap
368
453
  * @param value 待检查值
369
454
  * @returns 是否为 WeakMap
455
+ * @example
456
+ * ```ts
457
+ * TypeUtil.isWeakMap(new WeakMap()); // true
458
+ * ```
370
459
  */
371
460
  static isWeakMap(value) {
372
461
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.WEAK_MAP;
@@ -375,6 +464,10 @@ var TypeUtil = class {
375
464
  * 检查 value 是否为 Set
376
465
  * @param value 待检查值
377
466
  * @returns 是否为 Set
467
+ * @example
468
+ * ```ts
469
+ * TypeUtil.isSet(new Set()); // true
470
+ * ```
378
471
  */
379
472
  static isSet(value) {
380
473
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.SET;
@@ -383,6 +476,10 @@ var TypeUtil = class {
383
476
  * 检查 value 是否为 WeakSet
384
477
  * @param value 待检查值
385
478
  * @returns 是否为 WeakSet
479
+ * @example
480
+ * ```ts
481
+ * TypeUtil.isWeakSet(new WeakSet()); // true
482
+ * ```
386
483
  */
387
484
  static isWeakSet(value) {
388
485
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.WEAK_SET;
@@ -391,6 +488,10 @@ var TypeUtil = class {
391
488
  * 检查 value 是否为 Blob
392
489
  * @param value 待检查值
393
490
  * @returns 是否为 Blob
491
+ * @example
492
+ * ```ts
493
+ * TypeUtil.isBlob(new Blob(["a"])); // true
494
+ * ```
394
495
  */
395
496
  static isBlob(value) {
396
497
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.BLOB;
@@ -399,6 +500,10 @@ var TypeUtil = class {
399
500
  * 检查 value 是否为 File
400
501
  * @param value 待检查值
401
502
  * @returns 是否为 File
503
+ * @example
504
+ * ```ts
505
+ * TypeUtil.isFile(new File(["a"], "a.txt")); // true
506
+ * ```
402
507
  */
403
508
  static isFile(value) {
404
509
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.FILE;
@@ -412,6 +517,10 @@ var TypeUtil = class {
412
517
  *
413
518
  * @param value 待检查值
414
519
  * @returns 是否为 ReadableStream
520
+ * @example
521
+ * ```ts
522
+ * TypeUtil.isReadableStream(new ReadableStream()); // true
523
+ * ```
415
524
  */
416
525
  static isReadableStream(value) {
417
526
  if (this.getPrototypeString(value) === this.PROTOTYPE_TAGS.READABLE_STREAM) return true;
@@ -421,6 +530,10 @@ var TypeUtil = class {
421
530
  * 检查 value 是否为 Window
422
531
  * @param value 待检查值
423
532
  * @returns 是否为 Window
533
+ * @example
534
+ * ```ts
535
+ * TypeUtil.isWindow(window); // true
536
+ * ```
424
537
  */
425
538
  static isWindow(value) {
426
539
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.WINDOW;
@@ -429,6 +542,10 @@ var TypeUtil = class {
429
542
  * 检查 value 是否为 HTMLIFrameElement
430
543
  * @param value 待检查值
431
544
  * @returns 是否为 HTMLIFrameElement
545
+ * @example
546
+ * ```ts
547
+ * TypeUtil.isIframe(document.createElement("iframe")); // true
548
+ * ```
432
549
  */
433
550
  static isIframe(value) {
434
551
  if (typeof window === "undefined") return false;
@@ -467,6 +584,10 @@ var TypeUtil = class {
467
584
  * 检查 value 是否为 Error 对象
468
585
  * @param value 待检查值
469
586
  * @returns 是否为 Error
587
+ * @example
588
+ * ```ts
589
+ * TypeUtil.isError(new Error("x")); // true
590
+ * ```
470
591
  */
471
592
  static isError(value) {
472
593
  return value instanceof Error || this.getPrototypeString(value) === this.PROTOTYPE_TAGS.ERROR;
@@ -475,6 +596,10 @@ var TypeUtil = class {
475
596
  * 检查 value 是否为 RegExp
476
597
  * @param value 待检查值
477
598
  * @returns 是否为 RegExp
599
+ * @example
600
+ * ```ts
601
+ * TypeUtil.isRegExp(/a/); // true
602
+ * ```
478
603
  */
479
604
  static isRegExp(value) {
480
605
  if (typeof value !== "object" || value === null) return false;
@@ -489,6 +614,10 @@ var TypeUtil = class {
489
614
  * 检查 value 是否为 WebSocket
490
615
  * @param value 待检查值
491
616
  * @returns 是否为 WebSocket
617
+ * @example
618
+ * ```ts
619
+ * TypeUtil.isWebSocket(new WebSocket("wss://echo.websocket.events")); // true
620
+ * ```
492
621
  */
493
622
  static isWebSocket(value) {
494
623
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.WEB_SOCKET;
@@ -497,6 +626,10 @@ var TypeUtil = class {
497
626
  * 检查 value 是否为 URLSearchParams
498
627
  * @param value 待检查值
499
628
  * @returns 是否为 URLSearchParams
629
+ * @example
630
+ * ```ts
631
+ * TypeUtil.isURLSearchParams(new URLSearchParams("a=1")); // true
632
+ * ```
500
633
  */
501
634
  static isURLSearchParams(value) {
502
635
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.URL_SEARCH_PARAMS;
@@ -505,6 +638,10 @@ var TypeUtil = class {
505
638
  * 检查 value 是否为 AbortSignal
506
639
  * @param value 待检查值
507
640
  * @returns 是否为 AbortSignal
641
+ * @example
642
+ * ```ts
643
+ * TypeUtil.isAbortSignal(new AbortController().signal); // true
644
+ * ```
508
645
  */
509
646
  static isAbortSignal(value) {
510
647
  return this.getPrototypeString(value) === this.PROTOTYPE_TAGS.ABORT_SIGNAL;
@@ -513,6 +650,10 @@ var TypeUtil = class {
513
650
  * 检查 value 是否为可迭代对象 (Iterable)
514
651
  * @param value 待检查值
515
652
  * @returns 是否为 Iterable
653
+ * @example
654
+ * ```ts
655
+ * TypeUtil.isIterable([1, 2]); // true
656
+ * ```
516
657
  */
517
658
  static isIterable(value) {
518
659
  return !!value && typeof value[Symbol.iterator] === "function";
@@ -521,11 +662,27 @@ var TypeUtil = class {
521
662
  * 检查 value 是否为 Falsy 值 (false, 0, "", null, undefined, NaN)
522
663
  * @param value 待检查值
523
664
  * @returns 是否为 Falsy
665
+ * @example
666
+ * ```ts
667
+ * TypeUtil.isFalsy(0); // true
668
+ * ```
524
669
  */
525
670
  static isFalsy(value) {
526
671
  if (this.isNaN(value) || this.isNull(value) || this.isUndefined(value)) return true;
527
672
  return value === false || value === 0 || value === 0n || value === "";
528
673
  }
674
+ /**
675
+ * 检查 value 是否为 FalsyLike 值
676
+ * - 包含字符串形式的 `"null"`、`"undefined"`、`"false"`、`"0"` 等
677
+ *
678
+ * @param value 待检查值
679
+ * @returns 是否为 FalsyLike
680
+ * @example
681
+ * ```ts
682
+ * TypeUtil.isFalsyLike("false"); // true
683
+ * TypeUtil.isFalsyLike("hello"); // false
684
+ * ```
685
+ */
529
686
  static isFalsyLike(value) {
530
687
  if (this.isFalsy(value)) return true;
531
688
  return typeof value === "string" && (value === "null" || value === "undefined" || value === "NaN" || value === "false" || value === "0" || value === "-0" || value === "0n");
@@ -9,6 +9,19 @@ declare class ViteUtil {
9
9
  * 开发服务器反向代理配置
10
10
  *
11
11
  * @param proxyList 代理配置项
12
+ * @param options 追加到每个代理项的 Vite `ProxyOptions`
13
+ * @returns Vite `server.proxy` 可直接使用的配置对象
14
+ * @example
15
+ * ```ts
16
+ * ViteUtil.toProxy([
17
+ * ["/api", "http://localhost:3000"],
18
+ * ["/mock", "https://example.com"],
19
+ * ]);
20
+ * // {
21
+ * // "/api": { target: "http://localhost:3000", changeOrigin: true, ws: true, rewrite: [Function] },
22
+ * // "/mock": { target: "https://example.com", changeOrigin: true, ws: true, secure: false, rewrite: [Function] }
23
+ * // }
24
+ * ```
12
25
  */
13
26
  static toProxy<L extends [string, string][]>(proxyList: L, options?: ProxyOptions | undefined): Record<string, ProxyOptions>;
14
27
  }
@@ -7,6 +7,19 @@ var ViteUtil = class {
7
7
  * 开发服务器反向代理配置
8
8
  *
9
9
  * @param proxyList 代理配置项
10
+ * @param options 追加到每个代理项的 Vite `ProxyOptions`
11
+ * @returns Vite `server.proxy` 可直接使用的配置对象
12
+ * @example
13
+ * ```ts
14
+ * ViteUtil.toProxy([
15
+ * ["/api", "http://localhost:3000"],
16
+ * ["/mock", "https://example.com"],
17
+ * ]);
18
+ * // {
19
+ * // "/api": { target: "http://localhost:3000", changeOrigin: true, ws: true, rewrite: [Function] },
20
+ * // "/mock": { target: "https://example.com", changeOrigin: true, ws: true, secure: false, rewrite: [Function] }
21
+ * // }
22
+ * ```
10
23
  */
11
24
  static toProxy(proxyList, options) {
12
25
  const httpsRE = /^https:\/\//;