Skip to content

Commit

Permalink
spaceCase added
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownJoe796 committed Oct 20, 2023
1 parent e07efc1 commit 2a09653
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ inline fun String.caseAlter(crossinline update: (after: String) -> String): Stri
private fun String.capitalize(): String = replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }
private fun String.decapitalize(): String = replaceFirstChar { if (it.isUpperCase()) it.lowercase(Locale.getDefault()) else it.toString() }

fun String.titleCase() =
caseAlter { " " + it.capitalize() }.capitalize()

fun String.titleCase() = caseAlter { " " + it.capitalize() }.capitalize()
fun String.spaceCase() = caseAlter { " " + it }.decapitalize()
fun String.kabobCase() = caseAlter { "-$it" }.lowercase()
fun String.snakeCase() = caseAlter { "_$it" }.lowercase()
fun String.screamingSnakeCase() = caseAlter { "_$it" }.uppercase()
Expand Down

0 comments on commit 2a09653

Please sign in to comment.