Documentation
¶
Index ¶
- Variables
- func CamelCase[T ~string]() func(destination ro.Observable[T]) ro.Observable[T]
- func Capitalize[T ~string]() func(destination ro.Observable[T]) ro.Observable[T]
- func Ellipsis[T ~string](length int) func(destination ro.Observable[T]) ro.Observable[T]
- func KebabCase[T ~string]() func(destination ro.Observable[T]) ro.Observable[T]
- func PascalCase[T ~string]() func(destination ro.Observable[T]) ro.Observable[T]
- func Random[T any](size int, charset []rune) func(destination ro.Observable[T]) ro.Observable[string]
- func SnakeCase[T ~string]() func(destination ro.Observable[T]) ro.Observable[T]
- func Words[T ~string]() func(destination ro.Observable[T]) ro.Observable[[]T]
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( LowerCaseLettersCharset = []rune("abcdefghijklmnopqrstuvwxyz") UpperCaseLettersCharset = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ") LettersCharset = append(LowerCaseLettersCharset, UpperCaseLettersCharset...) NumbersCharset = []rune("0123456789") AlphanumericCharset = append(LettersCharset, NumbersCharset...) SpecialCharset = []rune("!@#$%^&*()_+-=[]{}|;':\",./<>?") AllCharset = append(AlphanumericCharset, SpecialCharset...) )
Functions ¶
func CamelCase ¶
func CamelCase[T ~string]() func(destination ro.Observable[T]) ro.Observable[T]
CamelCase converts the string to camel case. Play: https://go.dev/play/p/MMmhpwApG1y
Example ¶
// Convert strings to camelCase format observable := ro.Pipe1( ro.Just( "hello world", "user_name", "API_KEY", "camel case", ), CamelCase[string](), ) subscription := observable.Subscribe(ro.PrintObserver[string]()) defer subscription.Unsubscribe()
Output: Next: helloWorld Next: userName Next: apiKey Next: camelCase Completed
func Capitalize ¶
func Capitalize[T ~string]() func(destination ro.Observable[T]) ro.Observable[T]
Capitalize capitalizes the first letter of the string. Play: https://go.dev/play/p/7hK8m9jL3nS
Example ¶
// Capitalize the first letter of each string observable := ro.Pipe1( ro.Just( "hello", "world", "golang", ), Capitalize[string](), ) subscription := observable.Subscribe(ro.PrintObserver[string]()) defer subscription.Unsubscribe()
Output: Next: Hello Next: World Next: Golang Completed
func Ellipsis ¶
func Ellipsis[T ~string](length int) func(destination ro.Observable[T]) ro.Observable[T]
Ellipsis truncates the string to the specified length and appends "..." if the string is longer than the specified length. Play: https://go.dev/play/p/Yqx1pUep0uX
Example ¶
// Truncate strings with ellipsis observable := ro.Pipe1( ro.Just( "This is a very long string that needs to be truncated", "Short", "Another long string for demonstration", ), Ellipsis[string](20), ) subscription := observable.Subscribe(ro.PrintObserver[string]()) defer subscription.Unsubscribe()
Output: Next: This is a very lo... Next: Short Next: Another long stri... Completed
func KebabCase ¶
func KebabCase[T ~string]() func(destination ro.Observable[T]) ro.Observable[T]
KebabCase converts the string to kebab case. Play: https://go.dev/play/p/Ndj3Gy2lztd
Example ¶
// Convert strings to kebab-case format observable := ro.Pipe1( ro.Just( "hello world", "userName", "API_KEY", "camelCase", ), KebabCase[string](), ) subscription := observable.Subscribe(ro.PrintObserver[string]()) defer subscription.Unsubscribe()
Output: Next: hello-world Next: user-name Next: api-key Next: camel-case Completed
func PascalCase ¶
func PascalCase[T ~string]() func(destination ro.Observable[T]) ro.Observable[T]
PascalCase converts the string to pascal case. Play: https://go.dev/play/p/107SvPGvHAK
Example ¶
// Convert strings to PascalCase format observable := ro.Pipe1( ro.Just( "hello world", "user_name", "api_key", "camel case", ), PascalCase[string](), ) subscription := observable.Subscribe(ro.PrintObserver[string]()) defer subscription.Unsubscribe()
Output: Next: HelloWorld Next: UserName Next: ApiKey Next: CamelCase Completed
func Random ¶
func Random[T any](size int, charset []rune) func(destination ro.Observable[T]) ro.Observable[string]
Random generates a random string of the specified size using the specified charset. Play: https://go.dev/play/p/7oDIGRxvrGt
Example ¶
// Generate random strings observable := ro.Pipe1( ro.Just(1, 2, 3), Random[int](10, AlphanumericCharset), ) subscription := observable.Subscribe(ro.NoopObserver[string]()) defer subscription.Unsubscribe()
func SnakeCase ¶
func SnakeCase[T ~string]() func(destination ro.Observable[T]) ro.Observable[T]
SnakeCase converts the string to snake case. Play: https://go.dev/play/p/hlGVKI-dR4y
Example ¶
// Convert strings to snake_case format observable := ro.Pipe1( ro.Just( "hello world", "userName", "API_KEY", "camelCase", ), SnakeCase[string](), ) subscription := observable.Subscribe(ro.PrintObserver[string]()) defer subscription.Unsubscribe()
Output: Next: hello_world Next: user_name Next: api_key Next: camel_case Completed
func Words ¶
func Words[T ~string]() func(destination ro.Observable[T]) ro.Observable[[]T]
Words splits the string into words. Play: https://go.dev/play/p/fVW5bSK7ltj
Example ¶
// Split strings into words observable := ro.Pipe1( ro.Just( "hello world", "user_name", "camelCase", "PascalCase", ), Words[string](), ) subscription := observable.Subscribe(ro.PrintObserver[[]string]()) defer subscription.Unsubscribe()
Output: Next: [hello world] Next: [user name] Next: [camel Case] Next: [Pascal Case] Completed
Types ¶
This section is empty.