Documentation ¶
Index ¶
- func Bind[FirstParamType, ParamType, ReturnType any](secondParam ParamType, callback func(FirstParamType, ParamType) ReturnType) func(FirstParamType) ReturnType
- func Comparator[T constraints.Ordered](a, b T) int
- func Compare[A constraints.Ordered](a, b A) int
- func Cond[T any](condition bool, trueValue, falseValue T) T
- func CopySlice[T any](base []T) (copied []T)
- func Filter[V any](collection []V, predicate func(V) bool) []V
- func FilterByValue[K comparable, V any](collection map[K]V, predicate func(V) bool) map[K]V
- func ForEach[T any](collection []T, iteratee func(T))
- func KeyBy[K comparable, V any](collection []V, iteratee func(V) K) map[K]V
- func KeyOnlyBy[K comparable, V any](collection []V, iteratee func(V) K) map[K]types.Empty
- func Keys[K comparable, V any](in map[K]V) []K
- func Map[SourceType any, TargetType any](source []SourceType, mapper func(SourceType) TargetType) (target []TargetType)
- func Max[T constraints.Ordered](collection ...T) T
- func MergeMaps[K comparable, V any](base, update map[K]V) map[K]V
- func Min[T constraints.Ordered](collection ...T) T
- func PanicOnErr[T any](result T, err error) T
- func Reduce[T any, R any](collection []T, accumulator func(R, T) R, initial R) R
- func ReduceProperty[A, B, C any](collection []A, propertyResolver func(A) B, accumulator func(C, B) C, ...) C
- func Return1[A any](a A, _ ...any) A
- func Return2[A any](_ any, a A, _ ...any) A
- func Return3[A any](_, _ any, a A, _ ...any) A
- func Return4[A any](_, _, _ any, a A, _ ...any) A
- func Return5[A any](_, _, _, _ any, a A, _ ...any) A
- func Sum[T constraints.Numeric](collection ...T) T
- func Unique[T comparable](collection []T) (unique *set.AdvancedSet[T])
- func Values[K comparable, V any](in map[K]V) []V
- func Void[A, B any](f func(A) B) func(A)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bind ¶
func Bind[FirstParamType, ParamType, ReturnType any](secondParam ParamType, callback func(FirstParamType, ParamType) ReturnType) func(FirstParamType) ReturnType
Bind generates a call wrapper with the second parameter's value fixed.
func Comparator ¶
func Comparator[T constraints.Ordered](a, b T) int
Comparator is a generic comparator for two values. It returns 0 if the two values are equal, -1 if the first value is smaller and 1 if the first value is larger.
func Compare ¶
func Compare[A constraints.Ordered](a, b A) int
Compare returns -1, 0 or 1 if the first parameter is smaller, equal or greater than the second argument.
func Cond ¶
Cond is a conditional statement that returns the trueValue if the condition is true and the falseValue otherwise.
func CopySlice ¶
func CopySlice[T any](base []T) (copied []T)
CopySlice copies the base slice into copied and returns the copy.
func Filter ¶
Filter iterates over elements of collection, returning an array of all elements predicate returns truthy for.
func FilterByValue ¶
func FilterByValue[K comparable, V any](collection map[K]V, predicate func(V) bool) map[K]V
FilterByValue iterates over the map, returning a map of all elements predicate returns truthy for.
func ForEach ¶
func ForEach[T any](collection []T, iteratee func(T))
ForEach iterates over elements of collection and invokes iteratee for each element.
func KeyBy ¶
func KeyBy[K comparable, V any](collection []V, iteratee func(V) K) map[K]V
KeyBy transforms a slice or an array of structs to a map based on a pivot callback.
func KeyOnlyBy ¶
func KeyOnlyBy[K comparable, V any](collection []V, iteratee func(V) K) map[K]types.Empty
KeyOnlyBy transforms a slice or an array of structs to a map containing the keys based on a pivot callback.
func Map ¶
func Map[SourceType any, TargetType any](source []SourceType, mapper func(SourceType) TargetType) (target []TargetType)
Map iterates over elements of collection, applies the mapper function to each element and returns an array of modified TargetType elements.
func Max ¶
func Max[T constraints.Ordered](collection ...T) T
Max returns the maximum value of the collection.
func MergeMaps ¶
func MergeMaps[K comparable, V any](base, update map[K]V) map[K]V
MergeMaps updates the base map with values from the update map and returns the extended base map.
func Min ¶
func Min[T constraints.Ordered](collection ...T) T
Min returns the minimum value of the collection.
func PanicOnErr ¶
PanicOnErr panics of the seconds parameter is an error and returns the first parameter otherwise.
func Reduce ¶
Reduce reduces collection to a value which is the accumulated result of running each element in collection through accumulator, where each successive invocation is supplied the return value of the previous.
func ReduceProperty ¶
func ReduceProperty[A, B, C any](collection []A, propertyResolver func(A) B, accumulator func(C, B) C, initial C) C
ReduceProperty reduces collection to a value which is the accumulated result of running each element in collection through property resolver, which extracts a value to be reduced from the type, and then accumulator, where each successive invocation is supplied the return value of the previous.
func Sum ¶
func Sum[T constraints.Numeric](collection ...T) T
Sum returns the sum of the collection.
func Unique ¶
func Unique[T comparable](collection []T) (unique *set.AdvancedSet[T])
Unique returns a set of unique elements from the collection.
func Values ¶
func Values[K comparable, V any](in map[K]V) []V
Values creates an array of the map values.
Types ¶
This section is empty.