@pawover/kit 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -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.
|
|
333
|
+
return this.isPromise(value) || this.isPlainObject(value, false) && this.isFunction(value["then"]);
|
|
328
334
|
}
|
|
329
335
|
/**
|
|
330
336
|
* 判断是否为普通对象类型
|
|
@@ -332,18 +338,19 @@ var TypeUtil = class {
|
|
|
332
338
|
*
|
|
333
339
|
* @param value 待检查值
|
|
334
340
|
* @param prototypeCheck 是否进行原型检查,默认 `true`
|
|
335
|
-
* @returns 是否为 Plain Object (当
|
|
341
|
+
* @returns 是否为 Plain Object (当 prototypeCheck=true) 或 object
|
|
336
342
|
* @example
|
|
337
343
|
* ```ts
|
|
338
|
-
* TypeUtil.
|
|
339
|
-
* TypeUtil.
|
|
340
|
-
* TypeUtil.
|
|
341
|
-
* TypeUtil.
|
|
342
|
-
* TypeUtil.
|
|
343
|
-
* TypeUtil.
|
|
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
|
|
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
|
}
|
|
@@ -527,7 +534,7 @@ var TypeUtil = class {
|
|
|
527
534
|
*/
|
|
528
535
|
static isReadableStream(value) {
|
|
529
536
|
if (this.getPrototypeString(value) === this.PROTOTYPE_TAGS.READABLE_STREAM) return true;
|
|
530
|
-
return this.
|
|
537
|
+
return this.isPlainObject(value) && this.isFunction(value["getReader"]) && this.isFunction(value["pipeThrough"]);
|
|
531
538
|
}
|
|
532
539
|
/**
|
|
533
540
|
* 检查 value 是否为 Window
|
|
@@ -691,50 +698,6 @@ var TypeUtil = class {
|
|
|
691
698
|
return typeof value === "string" && (value === "null" || value === "undefined" || value === "NaN" || value === "false" || value === "0" || value === "-0" || value === "0n");
|
|
692
699
|
}
|
|
693
700
|
};
|
|
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
701
|
//#endregion
|
|
739
702
|
//#region src/string/stringUtil.ts
|
|
740
703
|
/**
|
|
@@ -848,8 +811,8 @@ var StringUtil = class {
|
|
|
848
811
|
let normalized = input.replace(/^[A-Za-z]:([\\/])?/, (_, separator) => {
|
|
849
812
|
return separator ? "/" : "";
|
|
850
813
|
});
|
|
851
|
-
normalized = normalized.
|
|
852
|
-
normalized = normalized.
|
|
814
|
+
normalized = normalized.replaceAll("\\", "/");
|
|
815
|
+
normalized = normalized.replaceAll(/\/+/g, "/");
|
|
853
816
|
if (removeLeadingSlash && normalized.startsWith("/")) normalized = normalized.substring(1);
|
|
854
817
|
return normalized;
|
|
855
818
|
}
|
|
@@ -957,4 +920,4 @@ var StringUtil = class {
|
|
|
957
920
|
}
|
|
958
921
|
};
|
|
959
922
|
//#endregion
|
|
960
|
-
export { TypeUtil as n,
|
|
923
|
+
export { TypeUtil as n, StringUtil as t };
|