@ecan-bi/tools 1.0.62 → 1.0.64

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/src/utils/util.ts CHANGED
@@ -20,6 +20,37 @@ export const lowerCaseIncludes = (v1:any, v2:any): boolean => {
20
20
  }
21
21
  return false
22
22
  }
23
+ export const lowerCaseReplace = (strA: string, strB: string): string => {
24
+ // 空值保护
25
+ if (!strA || !strB) {
26
+ return strA || '';
27
+ }
28
+
29
+ // 不区分大小写判断是否以 strB 开头
30
+ if (strA.toLowerCase().startsWith(strB.toLowerCase())) {
31
+ // 删除 B 开头的部分(注意保持原字符串的大小写)
32
+ const remaining = strA.slice(strB.length);
33
+
34
+ // 如果剩余部分为空,直接返回空字符串
35
+ if (!remaining) {
36
+ return '';
37
+ }
38
+
39
+ // 首字母小写 + 其余部分保持不变
40
+ return remaining.charAt(0).toLowerCase() + remaining.slice(1);
41
+ }
42
+
43
+ // 不匹配则返回原字符串
44
+ return strA;
45
+ };
46
+ export const lowerCaseJoin = (strA: string, strB: string): string => {
47
+ // 空值保护
48
+ if (!strA || !strB) {
49
+ return strA || '';
50
+ }
51
+ return strB + strA.charAt(0).toUpperCase() + strA.slice(1)
52
+ };
53
+
23
54
 
24
55
  /**
25
56
  * 判断 key 是否在对象上