A mask is a formatting pattern that you can apply to a value. This module has some functions to help you create and apply masks.
Formats a string filtering only the numbers of it
number "(##) ####-####" "1234567890" == "(12) 3456-7890"
number "#-##-#" "1b0a" == "1-0"Options used to format numbers. decimal and thousand are the characters that separate each section of the number and precision is the number of decimal places
Default options to format numbers. Extend this if you want to customize the way numbers are formatted.
defaultDecimalOptions =
{ decimal = "."
, thousand = ","
, precision = 2
}Formats a Float number according to the specified options
floatDecimal defaultDecimalOptions 10500.5 == "10.500.50"
floatDecimal { defaultDecimalOptions | precision = 3, decimal = ",", thousand = "." } 10500.5 == "10.500,500"Formats a Int number according to the specified options
intDecimal defaultDecimalOptions 105005 == "1,050.05"
intDecimal { defaultDecimalOptions | precision = 3, decimal = "," } 105005 == "105,005"
Formats a string using a pattern. A pattern is a string where the
#is going to be replaced by a character of the input