ProductPromotion
Logo

Kotlin

made by https://0x3d.site

GitHub - dotCipher/kase-format: Multiplatform kotlin string case conversion and detection library.
Multiplatform kotlin string case conversion and detection library. - dotCipher/kase-format
Visit Site

GitHub - dotCipher/kase-format: Multiplatform kotlin string case conversion and detection library.

GitHub - dotCipher/kase-format: Multiplatform kotlin string case conversion and detection library.

KaseFormat

Download CircleCI Awesome Kotlin Badge

Multiplatform kotlin string case conversion and detection library.

examples

(Inspired by Guava's CaseFormat)

Setup

Declare repository

Include the following in your respositories block within the build.gradle.kts:

repositories {
    maven("https://dl.bintray.com/dotcipher/maven")
}

Or in groovy syntax for a build.gradle:

repositories {
    maven {
        url 'https://dl.bintray.com/dotcipher/maven'
    }   
}

Include dependency

Include the following in your dependencies block (replacing <version> with the latest release above:

dependencies {
        // JVM implementation
        implementation("io.dotcipher.kase:kase-format-jvm:<version>")

        // Native / JS implementations coming soon
}

Usage

KaseFormat is the main entrypoint for library usage, and it's defined as an enum of the following formats:

  • LOWER_HYPHEN (ie. hello-world)
  • CAPITAL_HYPHEN (ie. Hello-World)
  • UPPER_HYPHEN (ie. HELLO-WORLD)
  • LOWER_UNDERSCORE (ie. hello_world)
  • CAPITAL_UNDERSCORE (ie. Hello_World)
  • UPPER_UNDERSCORE (ie. HELLO_WORLD)
  • LOWER_CAMEL (ie. helloWorld)
  • CAPITAL_CAMEL (ie. HelloWorld)

Conversion

The most efficient way to convert is if the source format is known before conversion. For example, if the intent is to convert from LOWER_UNDERSCORE (ie. hello_world) to CAPITAL_CAMEL (ie. HelloWorld) then you could use the following syntax:

val str = "hello_world"
val output = KaseFormat.LOWER_UNDERSCORE.convert(KaseFormat.CAPITAL_CAMEL, str)
// output == "HelloWorld"

If the source format isn't known before conversion, then a KaseConverter needs to be created targeting the destination format. The KaseConverter can be reused and is thread-safe. For example if the intent is to convert into the LOWER_HYPHEN format from any unknown format then you can use the following syntax:

val strings = listOf("string_one", "STRING-TWO", "stringThree", "StringFour")
val converter = KaseFormat.LOWER_HYPHEN.converter()

val firstOutput = converter.convert(strings[0])
// firstOutput == "string-one"

val listOutput = converter.convert(strings.sublist(1, strings.size))
// listOutput == listOf("string-two", "string-three", "string-four")

Detection

Detection of what format a string might be (by best guess), can be accomplished using the following syntax:

val str = "someString"
val format = KaseFormat.determine(str)
// format == LOWER_CAMEL

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory