mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
61 lines
1.5 KiB
Text
61 lines
1.5 KiB
Text
api Str provides Str, isEmpty, join
|
|
|
|
## Types
|
|
|
|
## A sequence of [UTF-8](https://en.wikipedia.org/wiki/UTF-8) text characters.
|
|
##
|
|
## One #Str can be up to 2 gigabytes in size. If you need to store larger
|
|
## strings than that, you can split them into smaller chunks and operate
|
|
## on those instead of on one large #Str. This often runs faster in practice,
|
|
## even for strings much smaller than 2 gigabytes.
|
|
Str : [ @Str ]
|
|
|
|
## Convert
|
|
|
|
## Convert a #Float to a decimal string, rounding off to the given number of decimal places.
|
|
##
|
|
## Since #Float values are imprecise, it's usually best to limit this to the lowest
|
|
## number you can choose that will make sense for what you want to display.
|
|
##
|
|
## If you want to kep all the digits, passing #Int.highestSupported will accomplish this,
|
|
## but it's recommended to pass much smaller numbers instead.
|
|
##
|
|
## Passing a negative number for decimal places is equivalent to passing 0.
|
|
decimal : Int, Float -> Str
|
|
|
|
## Convert an #Int to a string.
|
|
int : Float -> Str
|
|
|
|
## Check
|
|
|
|
isEmpty : Str -> Bool
|
|
|
|
startsWith : Str, Str -> Bool
|
|
|
|
endsWith : Str, Str -> Bool
|
|
|
|
contains : Str, Str -> Bool
|
|
|
|
any : Str, Str -> Bool
|
|
|
|
all : Str, Str -> Bool
|
|
|
|
## Combine
|
|
|
|
## Combine a list of strings into a single string.
|
|
##
|
|
## >>> Str.join [ "a", "bc", "def" ]
|
|
join : List Str -> Str
|
|
|
|
## Combine a list of strings into a single string, with a separator
|
|
## string in between each.
|
|
##
|
|
## >>> Str.joinWith [ "one", "two", "three" ] ", "
|
|
joinWith : List Str, Str -> Str
|
|
|
|
|
|
padStart : Str, Int, Str -> Str
|
|
|
|
padEnd : Str, Int, Str -> Str
|
|
|
|
|