Documentation ¶
Overview ¶
Package strutil provides functional utils for string.
Index ¶
- type IString
- type String
- func (*String) CamelCase(input string, pascalCase ...bool) string
- func (*String) Concat(ints ...[]string) []string
- func (i *String) Difference(ints []string, vs ...[]string) []string
- func (*String) Drop(ints []string, n ...int) []string
- func (*String) Equal(s1, s2 []string) bool
- func (*String) Every(ints []string, predict func(string) bool) bool
- func (*String) Fill(ints []string, value string, startEndIndex ...int)
- func (*String) Filter(ints []string, predict func(string) bool) []string
- func (*String) Find(ints []string, predict func(string) bool) (string, bool)
- func (*String) FindIndex(ints []string, predict func(string) bool, fromIndex ...int) int
- func (*String) FindLastIndex(ints []string, predict func(string) bool, fromIndex ...int) int
- func (*String) ForEach(ints []string, provided func(string))
- func (*String) From(ints []string, mapFn ...func(string) string) []string
- func (*String) Head(ints []string) (string, bool)
- func (*String) Includes(ints []string, e string) bool
- func (*String) IndexOf(ints []string, e string, fromIndex ...int) int
- func (*String) Initial(ints []string) []string
- func (i *String) Intersection(vs ...[]string) []string
- func (*String) Join(ints []string, sep ...string) string
- func (*String) KebabCase(input string, separateDigit ...bool) string
- func (*String) Last(ints []string) (string, bool)
- func (*String) LastIndexOf(ints []string, e string, fromIndex ...int) int
- func (*String) Map(ints []string, m func(string) string) []string
- func (*String) Max(x, y string) string
- func (*String) Min(x, y string) string
- func (*String) Nth(ints []string, n ...int) (string, bool)
- func (*String) Of(ints ...string) []string
- func (*String) Pop(ints []string) (string, bool, []string)
- func (i *String) Pull(ints []string, vs ...string) []string
- func (*String) Push(ints []string, es ...string) (int, []string)
- func (*String) Reduce(ints []string, accum func(string, string) string, init ...string) string
- func (*String) ReduceRight(ints []string, accum func(string, string) string, init ...string) string
- func (*String) Remove(ints []string, predict func(string) bool) []string
- func (*String) Reverse(ints []string) []string
- func (*String) Shift(ints []string) (string, bool, []string)
- func (*String) Shuffle(ints []string)
- func (*String) Slice(ints []string, startEndIndex ...int) []string
- func (*String) SnakeCase(input string, separateDigit ...bool) string
- func (*String) Some(ints []string, predict func(string) bool) bool
- func (*String) Sort(ints []string, less ...func(int, int) bool)
- func (i *String) String(ints []string) string
- func (*String) Tail(ints []string) []string
- func (*String) Take(ints []string, n ...int) []string
- func (*String) Titleize(input string) string
- func (i *String) Union(ints ...[]string) []string
- func (i *String) Uniq(ints []string) []string
- func (*String) Unshift(ints []string, es ...string) (int, []string)
- func (i *String) Without(ints []string, vs ...string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IString ¶
type IString interface { Min(x, y string) string Max(x, y string) string Filter(ints []string, predict func(string) bool) []string Find(ints []string, predict func(string) bool) (string, bool) FindIndex(ints []string, predict func(string) bool, fromIndex ...int) int FindLastIndex(ints []string, predict func(string) bool, fromIndex ...int) int ForEach(ints []string, provided func(string)) Includes(ints []string, e string) bool IndexOf(ints []string, e string, fromIndex ...int) int LastIndexOf(ints []string, e string, fromIndex ...int) int From(ints []string, mapFn ...func(string) string) []string Of(ints ...string) []string Concat(ints ...[]string) []string Every(ints []string, predict func(string) bool) bool Some(ints []string, predict func(string) bool) bool Fill(ints []string, value string, startEndIndex ...int) Join(ints []string, sep ...string) string Map(ints []string, m func(string) string) []string Pop(ints []string) (string, bool, []string) Push(ints []string, es ...string) (int, []string) Reduce(ints []string, accum func(string, string) string, init ...string) string ReduceRight(ints []string, accum func(string, string) string, init ...string) string Reverse(ints []string) []string Shift(ints []string) (string, bool, []string) Unshift(ints []string, es ...string) (int, []string) Slice(ints []string, startEndIndex ...int) []string Sort(ints []string, less ...func(int, int) bool) Shuffle(ints []string) String(ints []string) string Drop(ints []string, n ...int) []string Head(ints []string) (string, bool) Initial(ints []string) []string Last(ints []string) (string, bool) Nth(ints []string, n ...int) (string, bool) Pull(ints []string, vs ...string) []string Difference(ints []string, vs ...[]string) []string Intersection(vs ...[]string) []string Without(ints []string, vs ...string) []string Remove(ints []string, predict func(string) bool) []string Tail(ints []string) []string Take(ints []string, n ...int) []string Union(ints ...[]string) []string Uniq(ints []string) []string Equal(s1, s2 []string) bool }
IString is the String interface.
type String ¶
type String struct{}
String for string type slice.
func (*String) CamelCase ¶
CamelCase convert dash/dot/underscore/space separated string to camelCase pascalCase define whether to uppercase the first character
func (*String) Difference ¶
Difference creates a slice of values not included in the other given slices.
func (*String) Fill ¶
Fill fills all the elements of a slice from a start index to an end index with a static value. the end index is not included.
func (*String) Filter ¶
Filter creates a new slice with all elements that pass the predict implemented.
func (*String) Find ¶
Find returns the value of the first element in the slice that satisfies the provided predict function. otherwise false is returned.
func (*String) FindIndex ¶
FindIndex returns the index of the first element in the slice that satisfies the provided predict function. otherwise -1 is returned.
func (*String) FindLastIndex ¶
FindLastIndex is like FindIndex except that it iterates over elements from right to left.
func (*String) Includes ¶
Includes determines whether a slice includes a certain element, returning true or false.
func (*String) IndexOf ¶
IndexOf returns the first index at which a given element can be found in the slice, or -1 if it is not present.
func (*String) Intersection ¶
Intersection creates a slice of unique values that are included in all given slices.
func (*String) KebabCase ¶
KebabCase convert string to kebab-case separateDigit define whether to separate digit from letter
func (*String) LastIndexOf ¶
LastIndexOf returns the last index at which a given element can be found in the slice, or -1 if it is not present.
func (*String) Map ¶
Map creates a new slice with the results of calling a provided function on every element in the calling slice.
func (*String) Nth ¶
Nth gets the element at index n of slice. if n is negative, the nth element from the end is returned.
func (*String) Push ¶
Push adds one or more elements to the end of a slice and returns the new length of the slice.
func (*String) Reduce ¶
Reduce applies a function against each element in the slice to reduce it to a single value.
func (*String) ReduceRight ¶
ReduceRight applies a function against each value of the slice (from right-to-left) to reduce it to a single value.
func (*String) Slice ¶
Slice returns a portion of a slice selected from start to end (end not included). start and end indexes are optional, default to zero and length of the slice.
func (*String) SnakeCase ¶
SnakeCase convert string to snake_case separateDigit define whether to separate digit from letter
func (*String) Some ¶
Some tests whether at least one element in the slice pass the predict implemented.