File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments