@idlebox/common 1.4.8 → 1.4.9
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.
|
@@ -5,48 +5,56 @@ exports.ucfirst = ucfirst;
|
|
|
5
5
|
exports.lcfirst = lcfirst;
|
|
6
6
|
exports.linux_case = linux_case;
|
|
7
7
|
exports.linux_case_hyphen = linux_case_hyphen;
|
|
8
|
+
const splittersAndLower = /[-.\/_]+[a-z]/g;
|
|
8
9
|
/** @public */
|
|
9
10
|
function camelCase(str) {
|
|
10
11
|
return str
|
|
11
|
-
.replace(
|
|
12
|
+
.replace(splittersAndLower, (s) => {
|
|
12
13
|
return s[1]?.toUpperCase();
|
|
13
14
|
})
|
|
14
|
-
.replace(
|
|
15
|
+
.replace(spliters, '');
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Uppercase first char
|
|
18
19
|
* @public
|
|
19
20
|
*/
|
|
20
21
|
function ucfirst(str) {
|
|
21
|
-
|
|
22
|
+
if (!str)
|
|
23
|
+
return str;
|
|
24
|
+
return (str[0].toUpperCase() + str.slice(1));
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* lowercase first char
|
|
25
28
|
* @public
|
|
26
29
|
*/
|
|
27
30
|
function lcfirst(str) {
|
|
28
|
-
|
|
31
|
+
if (!str)
|
|
32
|
+
return str;
|
|
33
|
+
return (str[0].toLowerCase() + str.slice(1));
|
|
29
34
|
}
|
|
35
|
+
const prefixCapitals = /^[A-Z]+/;
|
|
36
|
+
const allCapitals = /[A-Z]+/g;
|
|
37
|
+
const spliters = /[-.\/_]+/g;
|
|
30
38
|
/** @public */
|
|
31
39
|
function linux_case(str) {
|
|
32
40
|
return str
|
|
33
|
-
.replace(
|
|
41
|
+
.replace(prefixCapitals, (s) => {
|
|
34
42
|
return s.toLowerCase();
|
|
35
43
|
})
|
|
36
|
-
.replace(
|
|
44
|
+
.replace(allCapitals, (s) => {
|
|
37
45
|
return `_${s.toLowerCase()}`;
|
|
38
46
|
})
|
|
39
|
-
.replace(
|
|
47
|
+
.replace(spliters, '_');
|
|
40
48
|
}
|
|
41
49
|
/** @public */
|
|
42
50
|
function linux_case_hyphen(str) {
|
|
43
51
|
return str
|
|
44
|
-
.replace(
|
|
52
|
+
.replace(prefixCapitals, (s) => {
|
|
45
53
|
return s.toLowerCase();
|
|
46
54
|
})
|
|
47
|
-
.replace(
|
|
55
|
+
.replace(allCapitals, (s) => {
|
|
48
56
|
return `-${s.toLowerCase()}`;
|
|
49
57
|
})
|
|
50
|
-
.replace(
|
|
58
|
+
.replace(spliters, '-');
|
|
51
59
|
}
|
|
52
60
|
//# sourceMappingURL=castCase.cjs.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
"../../../src/string/castCase.ts"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": ";;
|
|
9
|
+
"mappings": ";;AAEA,8BAMC;AAMD,0BAGC;AAMD,0BAGC;AAMD,gCASC;AAGD,8CASC;AArDD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,cAAc;AACd,SAAgB,SAAS,CAAC,GAAW;IACpC,OAAO,GAAG;SACR,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,EAAE,EAAE;QACjC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAC5B,CAAC,CAAC;SACD,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAmB,GAAM;IAC/C,IAAI,CAAC,GAAG;QAAE,OAAO,GAAU,CAAC;IAC5B,OAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAmB,GAAM;IAC/C,IAAI,CAAC,GAAG;QAAE,OAAO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,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAG/D;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAGjE;AAKD,cAAc;AACd,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,UASrC;AAED,cAAc;AACd,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,UAS5C"
|
|
10
10
|
}
|
|
@@ -1,45 +1,53 @@
|
|
|
1
|
+
const splittersAndLower = /[-.\/_]+[a-z]/g;
|
|
1
2
|
/** @public */
|
|
2
3
|
export function camelCase(str) {
|
|
3
4
|
return str
|
|
4
|
-
.replace(
|
|
5
|
+
.replace(splittersAndLower, (s) => {
|
|
5
6
|
return s[1]?.toUpperCase();
|
|
6
7
|
})
|
|
7
|
-
.replace(
|
|
8
|
+
.replace(spliters, '');
|
|
8
9
|
}
|
|
9
10
|
/**
|
|
10
11
|
* Uppercase first char
|
|
11
12
|
* @public
|
|
12
13
|
*/
|
|
13
14
|
export function ucfirst(str) {
|
|
14
|
-
|
|
15
|
+
if (!str)
|
|
16
|
+
return str;
|
|
17
|
+
return (str[0].toUpperCase() + str.slice(1));
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* lowercase first char
|
|
18
21
|
* @public
|
|
19
22
|
*/
|
|
20
23
|
export function lcfirst(str) {
|
|
21
|
-
|
|
24
|
+
if (!str)
|
|
25
|
+
return str;
|
|
26
|
+
return (str[0].toLowerCase() + str.slice(1));
|
|
22
27
|
}
|
|
28
|
+
const prefixCapitals = /^[A-Z]+/;
|
|
29
|
+
const allCapitals = /[A-Z]+/g;
|
|
30
|
+
const spliters = /[-.\/_]+/g;
|
|
23
31
|
/** @public */
|
|
24
32
|
export function linux_case(str) {
|
|
25
33
|
return str
|
|
26
|
-
.replace(
|
|
34
|
+
.replace(prefixCapitals, (s) => {
|
|
27
35
|
return s.toLowerCase();
|
|
28
36
|
})
|
|
29
|
-
.replace(
|
|
37
|
+
.replace(allCapitals, (s) => {
|
|
30
38
|
return `_${s.toLowerCase()}`;
|
|
31
39
|
})
|
|
32
|
-
.replace(
|
|
40
|
+
.replace(spliters, '_');
|
|
33
41
|
}
|
|
34
42
|
/** @public */
|
|
35
43
|
export function linux_case_hyphen(str) {
|
|
36
44
|
return str
|
|
37
|
-
.replace(
|
|
45
|
+
.replace(prefixCapitals, (s) => {
|
|
38
46
|
return s.toLowerCase();
|
|
39
47
|
})
|
|
40
|
-
.replace(
|
|
48
|
+
.replace(allCapitals, (s) => {
|
|
41
49
|
return `-${s.toLowerCase()}`;
|
|
42
50
|
})
|
|
43
|
-
.replace(
|
|
51
|
+
.replace(spliters, '-');
|
|
44
52
|
}
|
|
45
53
|
//# sourceMappingURL=castCase.js.map
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
"../../../src/string/castCase.ts"
|
|
7
7
|
],
|
|
8
8
|
"names": [],
|
|
9
|
-
"mappings": "AAAA,cAAc;AACd,MAAM,UAAU,SAAS,CAAC,GAAW;IACpC,OAAO,GAAG;SACR,OAAO,CAAC,
|
|
9
|
+
"mappings": "AAAA,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,cAAc;AACd,MAAM,UAAU,SAAS,CAAC,GAAW;IACpC,OAAO,GAAG;SACR,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,EAAE,EAAE;QACjC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAC5B,CAAC,CAAC;SACD,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAmB,GAAM;IAC/C,IAAI,CAAC,GAAG;QAAE,OAAO,GAAU,CAAC;IAC5B,OAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CA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
3
|
"type": "module",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./lib/cjs/__create_index.generated.cjs",
|
|
7
7
|
"module": "./lib/esm/__create_index.generated.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"repository": "https://github.com/GongT/baobao",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@rushstack/heft": "^0.68.2",
|
|
21
|
+
"@build-script/single-dog-asset": "^1.0.34",
|
|
21
22
|
"@internal/local-rig": "^1.0.1",
|
|
22
|
-
"@idlebox/itypes": "^1.0.7"
|
|
23
|
-
"@build-script/single-dog-asset": "^1.0.34"
|
|
23
|
+
"@idlebox/itypes": "^1.0.7"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"test": "heft test",
|
package/src/string/castCase.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
const splittersAndLower = /[-.\/_]+[a-z]/g;
|
|
1
2
|
/** @public */
|
|
2
3
|
export function camelCase(str: string) {
|
|
3
4
|
return str
|
|
4
|
-
.replace(
|
|
5
|
+
.replace(splittersAndLower, (s) => {
|
|
5
6
|
return s[1]?.toUpperCase();
|
|
6
7
|
})
|
|
7
|
-
.replace(
|
|
8
|
+
.replace(spliters, '');
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -12,7 +13,8 @@ export function camelCase(str: string) {
|
|
|
12
13
|
* @public
|
|
13
14
|
*/
|
|
14
15
|
export function ucfirst<T extends string>(str: T): Capitalize<T> {
|
|
15
|
-
|
|
16
|
+
if (!str) return str as any;
|
|
17
|
+
return <any>(str[0].toUpperCase() + str.slice(1));
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -20,29 +22,33 @@ export function ucfirst<T extends string>(str: T): Capitalize<T> {
|
|
|
20
22
|
* @public
|
|
21
23
|
*/
|
|
22
24
|
export function lcfirst<T extends string>(str: T): Uncapitalize<T> {
|
|
23
|
-
|
|
25
|
+
if (!str) return str as any;
|
|
26
|
+
return <any>(str[0].toLowerCase() + str.slice(1));
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
const prefixCapitals = /^[A-Z]+/;
|
|
30
|
+
const allCapitals = /[A-Z]+/g;
|
|
31
|
+
const spliters = /[-.\/_]+/g;
|
|
26
32
|
/** @public */
|
|
27
33
|
export function linux_case(str: string) {
|
|
28
34
|
return str
|
|
29
|
-
.replace(
|
|
35
|
+
.replace(prefixCapitals, (s) => {
|
|
30
36
|
return s.toLowerCase();
|
|
31
37
|
})
|
|
32
|
-
.replace(
|
|
38
|
+
.replace(allCapitals, (s) => {
|
|
33
39
|
return `_${s.toLowerCase()}`;
|
|
34
40
|
})
|
|
35
|
-
.replace(
|
|
41
|
+
.replace(spliters, '_');
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
/** @public */
|
|
39
45
|
export function linux_case_hyphen(str: string) {
|
|
40
46
|
return str
|
|
41
|
-
.replace(
|
|
47
|
+
.replace(prefixCapitals, (s) => {
|
|
42
48
|
return s.toLowerCase();
|
|
43
49
|
})
|
|
44
|
-
.replace(
|
|
50
|
+
.replace(allCapitals, (s) => {
|
|
45
51
|
return `-${s.toLowerCase()}`;
|
|
46
52
|
})
|
|
47
|
-
.replace(
|
|
53
|
+
.replace(spliters, '-');
|
|
48
54
|
}
|