qol_gleam/qol_string
Values
pub fn camel_case(string: String) -> String
Converts a String to a camelCase.
Examples
assert 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
assert 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
assert pad_both("121", to: 5, with: ".") == ".121."
assert pad_both("121", to: 3, with: ".") == "121"
assert 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
assert 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
assert 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
assert 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
assert to_words("Hello world") == ["Hello", "world"]
assert to_words("hello_world") == ["hello", "world"]
assert to_words("helloWorld") == ["hello", "World"]
assert to_words("HTTPNotFound404") == ["HTTP", "Not", "Found", "404"]
Origin
This function is commonly expected from other programming language.