qol_gleam/qol_string
Values
pub fn camel_case(string: String) -> String
Converts a String to a camelCase.
Examples
camel_case("Hello World")
// -> "helloWorld"
Origin
This function was from the justin package. However, this implement use gleam_regexp and Unicode awareness. On the other hand, justin implement don’t need regexp and run faster.
pub fn kebab_case(string: String) -> String
Converts a String to a kebab-case.
Examples
kabab_case("Hello World")
// -> "hello-world"
Origin
This function was from the justin package. However, this implement use gleam_regexp and Unicode awareness. On the other hand, justin implement don’t need regexp and run faster.
pub fn pad_both(
string: String,
to desired_length: Int,
with pad_string: String,
) -> String
Pads the start and the end of a String until it has a given length.
Examples
pad_both("121", to: 5, with: ".")
// -> ".121."
pad_both("121", to: 3, with: ".")
// -> "121"
pad_both("121", to: 2, with: ".")
// -> "121"
Origin
This function is commonly expected from other programming language.
pub fn pascal_case(string: String) -> String
Converts a String to a PascalCase.
Examples
pascal_case("Hello World")
// -> "HelloWorld"
Origin
This function was from the justin package. However, this implement use gleam_regexp and Unicode awareness. On the other hand, justin implement don’t need regexp and run faster.
pub fn sentence_case(string: String) -> String
Converts a String to a Sentence case.
Examples
sentence_case("hello-world")
// -> "Hello world"
Origin
This function was from the justin package. However, this implement use gleam_regexp and Unicode awareness. On the other hand, justin implement don’t need regexp and run faster.
pub fn snake_case(string: String) -> String
Converts a String to a snake_case.
Examples
snake_case("Hello World")
// -> "hello_world"
Origin
This function was from the justin package. However, this implement use gleam_regexp and Unicode awareness. On the other hand, justin implement don’t need regexp and run faster.
pub fn to_words(string: String) -> List(String)
Converts a String to a list of words.
Examples
to_words("Hello world")
// -> ["Hello", "world"]
to_words("hello_world")
// -> ["hello", "world"]
to_words("helloWorld")
// -> ["hello", "World"]
to_words("HTTPNotFound404")
// -> ["HTTP", "Not", "Found", "404"]
Origin
This function is commonly expected from other programming language.