@pawover/kit 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ function useLatest(value) {
|
|
|
11
11
|
return ref;
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
|
-
//#region ../utils/dist/stringUtil-
|
|
14
|
+
//#region ../utils/dist/stringUtil-voQaLOJj.js
|
|
15
15
|
/**
|
|
16
16
|
* 类型工具类
|
|
17
17
|
*/
|
|
@@ -732,12 +732,13 @@ var TypeUtil = class {
|
|
|
732
732
|
* 字符串工具类
|
|
733
733
|
*/
|
|
734
734
|
var StringUtil = class {
|
|
735
|
-
static cast(candidate, checkEmpty = true) {
|
|
735
|
+
static cast(candidate, checkEmpty = true, trim = true) {
|
|
736
736
|
if (checkEmpty) {
|
|
737
737
|
if (candidate === null || candidate === void 0) return "";
|
|
738
738
|
if (typeof candidate === "string" && candidate.trim().length === 0) return "";
|
|
739
739
|
}
|
|
740
|
-
|
|
740
|
+
const result = String(candidate);
|
|
741
|
+
return trim ? result.trim() : result;
|
|
741
742
|
}
|
|
742
743
|
/**
|
|
743
744
|
* 从字符串中提取数字字符串
|
|
@@ -3875,6 +3875,7 @@ declare class StringUtil {
|
|
|
3875
3875
|
*
|
|
3876
3876
|
* @param candidate 待转换的值
|
|
3877
3877
|
* @param checkEmpty 是否检查空值(`null` / `undefined` / 空白字符串),默认为 `true`
|
|
3878
|
+
* @param trim 是否去除结果首尾空白,默认为 `true`
|
|
3878
3879
|
* @returns 转换后的字符串
|
|
3879
3880
|
* @example
|
|
3880
3881
|
* ```ts
|
|
@@ -3896,12 +3897,17 @@ declare class StringUtil {
|
|
|
3896
3897
|
*
|
|
3897
3898
|
* // 重载 4: 其他类型 → string
|
|
3898
3899
|
* StringUtil.cast(Symbol("foo")); // "Symbol(foo)" (类型为 string)
|
|
3900
|
+
*
|
|
3901
|
+
* // trim 参数(默认 true)
|
|
3902
|
+
* StringUtil.cast(" hello "); // "hello"
|
|
3903
|
+
* StringUtil.cast("\n abc \n"); // "abc"
|
|
3904
|
+
* StringUtil.cast("\n abc \n", true, false); // "\n abc \n"
|
|
3899
3905
|
* ```
|
|
3900
3906
|
*/
|
|
3901
|
-
static cast<T extends null | undefined>(candidate: T, checkEmpty?: true): "";
|
|
3902
|
-
static cast<T extends null | undefined>(candidate: T, checkEmpty: false): `${T}`;
|
|
3903
|
-
static cast<T extends string | number | bigint | boolean>(candidate: T, checkEmpty?: boolean): `${T}`;
|
|
3904
|
-
static cast(candidate: unknown, checkEmpty?: boolean): string;
|
|
3907
|
+
static cast<T extends null | undefined>(candidate: T, checkEmpty?: true, trim?: boolean): "";
|
|
3908
|
+
static cast<T extends null | undefined>(candidate: T, checkEmpty: false, trim?: boolean): `${T}`;
|
|
3909
|
+
static cast<T extends string | number | bigint | boolean>(candidate: T, checkEmpty?: boolean, trim?: boolean): `${T}`;
|
|
3910
|
+
static cast(candidate: unknown, checkEmpty?: boolean, trim?: boolean): string;
|
|
3905
3911
|
/**
|
|
3906
3912
|
* 从字符串中提取数字字符串
|
|
3907
3913
|
* - 移除非数字字符,保留符号和小数点
|
|
@@ -721,12 +721,13 @@ var TypeUtil = class {
|
|
|
721
721
|
* 字符串工具类
|
|
722
722
|
*/
|
|
723
723
|
var StringUtil = class {
|
|
724
|
-
static cast(candidate, checkEmpty = true) {
|
|
724
|
+
static cast(candidate, checkEmpty = true, trim = true) {
|
|
725
725
|
if (checkEmpty) {
|
|
726
726
|
if (candidate === null || candidate === void 0) return "";
|
|
727
727
|
if (typeof candidate === "string" && candidate.trim().length === 0) return "";
|
|
728
728
|
}
|
|
729
|
-
|
|
729
|
+
const result = String(candidate);
|
|
730
|
+
return trim ? result.trim() : result;
|
|
730
731
|
}
|
|
731
732
|
/**
|
|
732
733
|
* 从字符串中提取数字字符串
|