import String from "String" #iftarget js toShort :: Char -> Short export toShort = (c) => #- c.codePointAt(0) -# fromShort :: Short -> Char export fromShort = (s) => #- String.fromCodePoint(s) -# #elseif llvm toShort :: Char -> Short export toShort = extern "madlib__number__charToShort" fromShort :: Short -> Char export fromShort = extern "madlib__number__shortToChar" #endif /** * Returns true if the character is a digit, false otherwise. * * @since 0.13.0 * @example * isDigit('a') // false * isDigit('3') // true */ isDigit :: Char -> Boolean export isDigit = (s) => s == '0' || s == '1' || s == '2' || s == '3' || s == '4' || s == '5' || s == '6' || s == '7' || s == '8' || s == '9' /** * Returns true if the character is a letter, false otherwise. Note that if the * input contains more than one character, false is returned. * @since 0.13.0 * @example * isLetter('0') // false * isLetter('=') // false * isLetter('a') // true */ isLetter :: Char -> Boolean export isLetter = (c) => pipe( String.prependChar($, ""), String.match("[a-zA-Z]+"), )(c) #iftarget js /** * Returns the lower cased version of a character * @since 0.13.0 * @example * toLower('A') // 'a' * toLower('a') // 'a' */ toLower :: Char -> Char export toLower = (c) => #- { return c.toLowerCase() } -# /** * Returns the upper cased version of a character * @since 0.13.0 * @example * toLower('A') // 'A' * toLower('a') // 'A' */ toUpper :: Char -> Char export toUpper = (c) => #- { return c.toUpperCase() } -# #elseif llvm /** * Returns the lower cased version of a character * @since 0.13.0 * @example * toLower('A') // 'a' * toLower('a') // 'a' */ toLower :: Char -> Char export toLower = extern "madlib__char__toLower" /** * Returns the upper cased version of a character * @since 0.13.0 * @example * toLower('A') // 'A' * toLower('a') // 'A' */ toUpper :: Char -> Char export toUpper = extern "madlib__char__toUpper" #endif