@pawover/kit 0.1.1 → 0.2.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.
@@ -1,4 +1,4 @@
1
- import { n as TypeUtil, t as StringUtil } from "./string-p6hZ1Mjb.js";
1
+ import { n as TypeUtil, t as StringUtil } from "./stringUtil-DbYpnL4l.js";
2
2
  //#region src/math/mathUtil.ts
3
3
  /**
4
4
  * 数学工具类
@@ -1,46 +1,52 @@
1
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
2
- function _typeof(o) {
3
- "@babel/helpers - typeof";
4
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
5
- return typeof o;
6
- } : function(o) {
7
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
8
- }, _typeof(o);
9
- }
10
- //#endregion
11
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
12
- function toPrimitive(t, r) {
13
- if ("object" != _typeof(t) || !t) return t;
14
- var e = t[Symbol.toPrimitive];
15
- if (void 0 !== e) {
16
- var i = e.call(t, r || "default");
17
- if ("object" != _typeof(i)) return i;
18
- throw new TypeError("@@toPrimitive must return a primitive value.");
19
- }
20
- return ("string" === r ? String : Number)(t);
21
- }
22
- //#endregion
23
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
24
- function toPropertyKey(t) {
25
- var i = toPrimitive(t, "string");
26
- return "symbol" == _typeof(i) ? i : i + "";
27
- }
28
- //#endregion
29
- //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
30
- function _defineProperty(e, r, t) {
31
- return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
32
- value: t,
33
- enumerable: !0,
34
- configurable: !0,
35
- writable: !0
36
- }) : e[r] = t, e;
37
- }
38
- //#endregion
39
1
  //#region src/type/typeUtil.ts
40
2
  /**
41
3
  * 类型工具类
42
4
  */
43
5
  var TypeUtil = class {
6
+ static PROTOTYPE_TAGS = {
7
+ STRING: "[object String]",
8
+ NUMBER: "[object Number]",
9
+ BOOLEAN: "[object Boolean]",
10
+ BIGINT: "[object BigInt]",
11
+ SYMBOL: "[object Symbol]",
12
+ UNDEFINED: "[object Undefined]",
13
+ NULL: "[object Null]",
14
+ OBJECT: "[object Object]",
15
+ FUNCTION: "[object Function]",
16
+ GENERATOR_FUNCTION: "[object GeneratorFunction]",
17
+ ASYNC_FUNCTION: "[object AsyncFunction]",
18
+ ASYNC_GENERATOR_FUNCTION: "[object AsyncGeneratorFunction]",
19
+ PROMISE: "[object Promise]",
20
+ MAP: "[object Map]",
21
+ SET: "[object Set]",
22
+ WEAK_MAP: "[object WeakMap]",
23
+ WEAK_SET: "[object WeakSet]",
24
+ BLOB: "[object Blob]",
25
+ FILE: "[object File]",
26
+ READABLE_STREAM: "[object ReadableStream]",
27
+ GLOBAL: "[object global]",
28
+ WINDOW: "[object Window]",
29
+ IFRAME: "[object HTMLIFrameElement]",
30
+ DATE: "[object Date]",
31
+ ERROR: "[object Error]",
32
+ REG_EXP: "[object RegExp]",
33
+ WEB_SOCKET: "[object WebSocket]",
34
+ URL_SEARCH_PARAMS: "[object URLSearchParams]",
35
+ ABORT_SIGNAL: "[object AbortSignal]"
36
+ };
37
+ static TYPED_ARRAY_TAGS = /* @__PURE__ */ new Set([
38
+ "[object Int8Array]",
39
+ "[object Uint8Array]",
40
+ "[object Uint8ClampedArray]",
41
+ "[object Int16Array]",
42
+ "[object Uint16Array]",
43
+ "[object Int32Array]",
44
+ "[object Uint32Array]",
45
+ "[object Float32Array]",
46
+ "[object Float64Array]",
47
+ "[object BigInt64Array]",
48
+ "[object BigUint64Array]"
49
+ ]);
44
50
  /**
45
51
  * 获取值的 [[Prototype]] 标签
46
52
  *
@@ -324,7 +330,7 @@ var TypeUtil = class {
324
330
  * ```
325
331
  */
326
332
  static isPromiseLike(value) {
327
- return this.isPromise(value) || this.isObject(value, false) && this.isFunction(value["then"]);
333
+ return this.isPromise(value) || this.isPlainObject(value, false) && this.isFunction(value["then"]);
328
334
  }
329
335
  /**
330
336
  * 判断是否为普通对象类型
@@ -332,22 +338,40 @@ var TypeUtil = class {
332
338
  *
333
339
  * @param value 待检查值
334
340
  * @param prototypeCheck 是否进行原型检查,默认 `true`
335
- * @returns 是否为 Plain Object (当 checkPrototype=true) 或 object
341
+ * @returns 是否为 Plain Object (当 prototypeCheck=true) 或 object
336
342
  * @example
337
343
  * ```ts
338
- * TypeUtil.isObject({}); // true
339
- * TypeUtil.isObject([]); // false
340
- * TypeUtil.isObject(new Date()); // false
341
- * TypeUtil.isObject(new Date(), false); // true
342
- * TypeUtil.isObject(Object.create(null)) // false
343
- * TypeUtil.isObject(Object.create(null), false) // true
344
+ * TypeUtil.isPlainObject({}); // true
345
+ * TypeUtil.isPlainObject([]); // false
346
+ * TypeUtil.isPlainObject(new Date()); // false
347
+ * TypeUtil.isPlainObject(new (class {})()); // false
348
+ * TypeUtil.isPlainObject(new (class {})(), false); // true
349
+ * TypeUtil.isPlainObject(Object.create(null)) // false
350
+ * TypeUtil.isPlainObject(Object.create(null), false) // true
344
351
  * ```
345
352
  */
346
- static isObject(value, prototypeCheck = true) {
353
+ static isPlainObject(value, prototypeCheck = true) {
347
354
  const check = this.getPrototypeString(value) === this.PROTOTYPE_TAGS.OBJECT;
348
355
  return prototypeCheck ? check && Object.getPrototypeOf(value) === Object.prototype : check;
349
356
  }
350
357
  /**
358
+ * 判断是否为广义对象类型
359
+ *
360
+ * @param value 待检查值
361
+ * @returns 是否为对象
362
+ * @example
363
+ * ```ts
364
+ * TypeUtil.isObject({}); // true
365
+ * TypeUtil.isObject([]); // true
366
+ * TypeUtil.isObject(new Date()); // true
367
+ * TypeUtil.isObject(null); // false
368
+ * TypeUtil.isObject("string"); // false
369
+ * ```
370
+ */
371
+ static isObject(value) {
372
+ return typeof value === "object" && value !== null;
373
+ }
374
+ /**
351
375
  * 判断一个对象是否为有效的枚举
352
376
  * - 枚举成员不能为空
353
377
  * - 枚举成员的键不能具有数值名
@@ -527,7 +551,7 @@ var TypeUtil = class {
527
551
  */
528
552
  static isReadableStream(value) {
529
553
  if (this.getPrototypeString(value) === this.PROTOTYPE_TAGS.READABLE_STREAM) return true;
530
- return this.isObject(value) && this.isFunction(value["getReader"]) && this.isFunction(value["pipeThrough"]);
554
+ return this.isPlainObject(value) && this.isFunction(value["getReader"]) && this.isFunction(value["pipeThrough"]);
531
555
  }
532
556
  /**
533
557
  * 检查 value 是否为 Window
@@ -691,50 +715,6 @@ var TypeUtil = class {
691
715
  return typeof value === "string" && (value === "null" || value === "undefined" || value === "NaN" || value === "false" || value === "0" || value === "-0" || value === "0n");
692
716
  }
693
717
  };
694
- _defineProperty(TypeUtil, "PROTOTYPE_TAGS", {
695
- STRING: "[object String]",
696
- NUMBER: "[object Number]",
697
- BOOLEAN: "[object Boolean]",
698
- BIGINT: "[object BigInt]",
699
- SYMBOL: "[object Symbol]",
700
- UNDEFINED: "[object Undefined]",
701
- NULL: "[object Null]",
702
- OBJECT: "[object Object]",
703
- FUNCTION: "[object Function]",
704
- GENERATOR_FUNCTION: "[object GeneratorFunction]",
705
- ASYNC_FUNCTION: "[object AsyncFunction]",
706
- ASYNC_GENERATOR_FUNCTION: "[object AsyncGeneratorFunction]",
707
- PROMISE: "[object Promise]",
708
- MAP: "[object Map]",
709
- SET: "[object Set]",
710
- WEAK_MAP: "[object WeakMap]",
711
- WEAK_SET: "[object WeakSet]",
712
- BLOB: "[object Blob]",
713
- FILE: "[object File]",
714
- READABLE_STREAM: "[object ReadableStream]",
715
- GLOBAL: "[object global]",
716
- WINDOW: "[object Window]",
717
- IFRAME: "[object HTMLIFrameElement]",
718
- DATE: "[object Date]",
719
- ERROR: "[object Error]",
720
- REG_EXP: "[object RegExp]",
721
- WEB_SOCKET: "[object WebSocket]",
722
- URL_SEARCH_PARAMS: "[object URLSearchParams]",
723
- ABORT_SIGNAL: "[object AbortSignal]"
724
- });
725
- _defineProperty(TypeUtil, "TYPED_ARRAY_TAGS", new Set([
726
- "[object Int8Array]",
727
- "[object Uint8Array]",
728
- "[object Uint8ClampedArray]",
729
- "[object Int16Array]",
730
- "[object Uint16Array]",
731
- "[object Int32Array]",
732
- "[object Uint32Array]",
733
- "[object Float32Array]",
734
- "[object Float64Array]",
735
- "[object BigInt64Array]",
736
- "[object BigUint64Array]"
737
- ]));
738
718
  //#endregion
739
719
  //#region src/string/stringUtil.ts
740
720
  /**
@@ -848,8 +828,8 @@ var StringUtil = class {
848
828
  let normalized = input.replace(/^[A-Za-z]:([\\/])?/, (_, separator) => {
849
829
  return separator ? "/" : "";
850
830
  });
851
- normalized = normalized.replace(/\\/g, "/");
852
- normalized = normalized.replace(/\/+/g, "/");
831
+ normalized = normalized.replaceAll("\\", "/");
832
+ normalized = normalized.replaceAll(/\/+/g, "/");
853
833
  if (removeLeadingSlash && normalized.startsWith("/")) normalized = normalized.substring(1);
854
834
  return normalized;
855
835
  }
@@ -957,4 +937,4 @@ var StringUtil = class {
957
937
  }
958
938
  };
959
939
  //#endregion
960
- export { TypeUtil as n, _defineProperty as r, StringUtil as t };
940
+ export { TypeUtil as n, StringUtil as t };