andre-dietrich / elm-conditional / Conditional.String

A collection of conditional functions to work with Strings.

Strings

reverseIf : Basics.Bool -> String -> String

Apply String.reverse if the first condition is met.

repeatIf : Basics.Bool -> Basics.Int -> String -> String

Apply String.repeat if the first condition is met.

replaceIf : Basics.Bool -> String -> String -> String -> String

Apply String.replace if the first condition is met.

Building and Splitting

addIf : Basics.Bool -> String -> String -> String

Add two Strings if the first parameter evalutes to True, otherwise the second defines the result

addWhen : Maybe String -> String -> String

Add two Strings if the first one is not of type Nothing

attachIf : Basics.Bool -> String -> String -> String

Add the first String to the end of the second one, if the first parameter evalutes to True.

attachWhen : Maybe String -> String -> String

Add the first String to the end of the second one, if it is not of type Nothing.

Get Substrings

sliceIf : Basics.Bool -> Basics.Int -> Basics.Int -> String -> String

Apply String.slice if the first condition is met.

leftIf : Basics.Bool -> Basics.Int -> String -> String

Apply String.left if the first condition is met.

rightIf : Basics.Bool -> Basics.Int -> String -> String

Apply String.right if the first condition is met.

dropLeftIf : Basics.Bool -> Basics.Int -> String -> String

Apply String.dropLeft if the first condition is met.

dropRightIf : Basics.Bool -> Basics.Int -> String -> String

Apply String.dropRight if the first condition is met.

Char Conversions

consIf : Basics.Bool -> Char -> String -> String

Apply String.cons if the first condition is met.

Formatting

Cosmetic operations such as padding with extra characters or trimming whitespace.

toUpperIf : Basics.Bool -> String -> String

Apply String.toUpper if the first condition is met.

toLowerIf : Basics.Bool -> String -> String

Apply String.toLower if the first condition is met.

padIf : Basics.Bool -> Basics.Int -> Char -> String -> String

Apply String.pad if the first condition is met.

padLeftIf : Basics.Bool -> Basics.Int -> Char -> String -> String

Apply String.padLeft if the first condition is met.

padRightIf : Basics.Bool -> Basics.Int -> Char -> String -> String

Apply String.padRight if the first condition is met.

trimIf : Basics.Bool -> String -> String

Apply String.trim if the first condition is met.

trimLeftIf : Basics.Bool -> String -> String

Apply String.trimLeft if the first condition is met.

trimRightIf : Basics.Bool -> String -> String

Apply String.trimRight if the first condition is met.

Higher-Order Functions

mapIf : Basics.Bool -> (Char -> Char) -> String -> String

Apply String.map if the first condition is met.

filterIf : Basics.Bool -> (Char -> Basics.Bool) -> String -> String

Apply String.filter if the first condition is met.