Skip to content

Commit 90b78f9

Browse files
committed
fix(utils): refine string helper
1 parent 619be58 commit 90b78f9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

packages/utils/src/lib/string.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ export function camelCaseToKebabCase<T extends string>(
3333
}
3434

3535
/**
36-
* Formats a slug to a readable title.
37-
* @param string - The slug to format.
36+
* Formats a string to a readable title.
37+
* @param stringToFormat - The string to format.
3838
* @returns The formatted title.
3939
*/
40-
export function kebabCaseToSentence(string = '') {
41-
return string
40+
export function kebabCaseToSentence(stringToFormat: string) {
41+
return stringToFormat
4242
.replace(/-/g, ' ')
4343
.replace(/\b\w/g, letter => letter.toUpperCase());
4444
}
4545

4646
/**
47-
* Formats a slug to a readable title.
48-
* @param string - The slug to format.
47+
* Formats a string to a readable title.
48+
* @param stringToFormat - The string to format.
4949
* @returns The formatted title.
5050
*/
51-
export function camelCaseToSentence(string = '') {
52-
return string
51+
export function camelCaseToSentence(stringToFormat : string) {
52+
return stringToFormat
5353
.replace(/([A-Z])([A-Z][a-z])/g, '$1-$2') // Split between uppercase followed by uppercase+lowercase
5454
.replace(/([a-z])([A-Z])/g, '$1-$2') // Split between lowercase followed by uppercase
5555
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2') // Additional split for consecutive uppercase

0 commit comments

Comments
 (0)