Documentation
¶
Overview ¶
Package stringutil Exports common rune utilities for parsing and emitting javascript
Index ¶
- func AddUTF8ByteOrderMark(text string) string
- func EncodeURI(s string) string
- func EquateStringCaseInsensitive(a, b string) bool
- func EquateStringCaseSensitive(a, b string) bool
- func Format(text string, args []any) string
- func GetStringComparer(ignoreCase bool) func(a, b string) Comparison
- func GetStringEqualityComparer(ignoreCase bool) func(a, b string) bool
- func GuessIndentation(lines []string) int
- func HasPrefix(s string, prefix string, caseSensitive bool) bool
- func HasSuffix(s string, suffix string, caseSensitive bool) bool
- func IsASCIILetter(ch rune) bool
- func IsDigit(ch rune) bool
- func IsHexDigit(ch rune) bool
- func IsLineBreak(ch rune) bool
- func IsOctalDigit(ch rune) bool
- func IsWhiteSpaceLike(ch rune) bool
- func IsWhiteSpaceSingleLine(ch rune) bool
- func LowerFirstChar(str string) string
- func RemoveByteOrderMark(text string) string
- func SplitLines(text string) []string
- func StripQuotes(name string) string
- func UnquoteString(str string) string
- type Comparison
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUTF8ByteOrderMark ¶
func GetStringComparer ¶
func GetStringComparer(ignoreCase bool) func(a, b string) Comparison
func GuessIndentation ¶
func IsASCIILetter ¶
func IsHexDigit ¶
func IsLineBreak ¶
func IsOctalDigit ¶
func IsWhiteSpaceLike ¶
func IsWhiteSpaceSingleLine ¶
func LowerFirstChar ¶
func RemoveByteOrderMark ¶
func SplitLines ¶
func StripQuotes ¶
func UnquoteString ¶
Types ¶
type Comparison ¶
type Comparison = int
const ( ComparisonLessThan Comparison = -1 ComparisonEqual Comparison = 0 ComparisonGreaterThan Comparison = 1 )
func CompareStringsCaseInsensitive ¶
func CompareStringsCaseInsensitive(a string, b string) Comparison
func CompareStringsCaseInsensitiveEslintCompatible ¶
func CompareStringsCaseInsensitiveEslintCompatible(a, b string) Comparison
CompareStringsCaseInsensitiveEslintCompatible performs a case-insensitive comparison using toLowerCase() instead of toUpperCase() for ESLint compatibility.
`CompareStringsCaseInsensitive` transforms letters to uppercase for unicode reasons, while eslint's `sort-imports` rule transforms letters to lowercase. Which one you choose affects the relative order of letters and ASCII characters 91-96, of which `_` is a valid character in an identifier. So if we used `CompareStringsCaseInsensitive` for import sorting, TypeScript and eslint would disagree about the correct case-insensitive sort order for `__String` and `Foo`. Since eslint's whole job is to create consistency by enforcing nitpicky details like this, it makes way more sense for us to just adopt their convention so users can have auto-imports without making eslint angry.
func CompareStringsCaseInsensitiveThenSensitive ¶
func CompareStringsCaseInsensitiveThenSensitive(a, b string) Comparison
func CompareStringsCaseSensitive ¶
func CompareStringsCaseSensitive(a string, b string) Comparison