Documentation
ΒΆ
Index ΒΆ
- func Assign[K comparable, V any](maps ...map[K]V) map[K]V
- func Chunk[T any](collection []T, size int) [][]T
- func Contains[T comparable](collection []T, element T) bool
- func Difference[T comparable](list1 []T, list2 []T) ([]T, []T)
- func Every[T comparable](collection []T, subset []T) bool
- func Fill[T Clonable[T]](collection []T, initial T) []T
- func Filter[V any](collection []V, predicate func(V, int) bool) []V
- func Find[T any](collection []T, predicate func(T) bool) (T, bool)
- func Flatten[T any](collection [][]T) []T
- func ForEach[T any](collection []T, iteratee func(T, int))
- func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V
- func GroupBy[T any, U comparable](collection []T, iteratee func(T) U) map[U][]T
- func If[T any](condition bool, result T) *ifElse[T]
- func IndexOf[T comparable](collection []T, element T) int
- func Intersect[T comparable](list1 []T, list2 []T) []T
- func Keys[K comparable, V any](in map[K]V) []K
- func Last[T any](collection []T) T
- func LastIndexOf[T comparable](collection []T, element T) int
- func Map[T any, R any](collection []T, iteratee func(T, int) R) []R
- func Max[T Ordered](collection []T) T
- func Min[T Ordered](collection []T) T
- func Nth[T any](collection []T, nth int) T
- func Reduce[T any, R any](collection []T, accumulator func(R, T, int) R, initial R) R
- func Reverse[T any](collection []T) []T
- func Shuffle[T any](collection []T) []T
- func Some[T comparable](collection []T, subset []T) bool
- func Switch[T comparable, R any](predicate T) *switchCase[T, R]
- func Ternary[T any](condition bool, ifOutput T, elseOutput T) T
- func ToMap[K comparable, V any](collection []V, iteratee func(V) K) map[K]V
- func ToPtr[T any](x T) *T
- func ToSlicePtr[T any](collection []T) []*T
- func Uniq[T comparable](collection []T) []T
- func UniqBy[T any, U comparable](collection []T, iteratee func(T) U) []T
- func Values[K comparable, V any](in map[K]V) []V
- type Clonable
- type Entry
- type Ordered
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func Assign ΒΆ
func Assign[K comparable, V any](maps ...map[K]V) map[K]V
Assign merges multiple maps from left to right.
func Chunk ΒΆ
Chunk returns an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.
func Contains ΒΆ
func Contains[T comparable](collection []T, element T) bool
Contains returns true if an element is present in a collection.
func Difference ΒΆ
func Difference[T comparable](list1 []T, list2 []T) ([]T, []T)
Difference returns the difference between two collections. The first value is the collection of element absent of list2. The second value is the collection of element absent of list1.
func Every ΒΆ
func Every[T comparable](collection []T, subset []T) bool
Every returns true if all elements of a subset are contained into a collection.
func Fill ΒΆ
func Fill[T Clonable[T]](collection []T, initial T) []T
Fill fills elements of array with `initial` value.
func Filter ΒΆ
Filter iterates over elements of collection, returning an array of all elements predicate returns truthy for.
func Find ΒΆ
Find search an element in a slice based on a predicate. It returns element and true if element was found.
func Flatten ΒΆ
func Flatten[T any](collection [][]T) []T
Flattens returns an array a single level deep.
func FromEntries ΒΆ
func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V
FromEntries transforms an array of key/value pairs into a map.
func GroupBy ΒΆ
func GroupBy[T any, U comparable](collection []T, iteratee func(T) U) map[U][]T
GroupBy returns an object composed of keys generated from the results of running each element of collection through iteratee.
func IndexOf ΒΆ
func IndexOf[T comparable](collection []T, element T) int
IndexOf returns the index at which the first occurrence of a value is found in an array or return -1 if the value cannot be found.
func Intersect ΒΆ
func Intersect[T comparable](list1 []T, list2 []T) []T
Intersect returns the intersection between two collections.
func Last ΒΆ
func Last[T any](collection []T) T
Last returns the last element of a collection or panics if empty.
func LastIndexOf ΒΆ
func LastIndexOf[T comparable](collection []T, element T) int
IndexOf returns the index at which the last occurrence of a value is found in an array or return -1 if the value cannot be found.
func Nth ΒΆ
Nth returns the element at index `nth` of collection. If `nth` is negative, the nth element from the end is returned.
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 Reverse ΒΆ
func Reverse[T any](collection []T) []T
Reverse reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.
func Shuffle ΒΆ
func Shuffle[T any](collection []T) []T
Shuffle returns an array of shuffled values.
func Some ΒΆ
func Some[T comparable](collection []T, subset []T) bool
Some returns true if at least 1 element of a subset is contained into a collection.
func Switch ΒΆ
func Switch[T comparable, R any](predicate T) *switchCase[T, R]
Switch is a pure functional switch/case/default statement.
func ToMap ΒΆ
func ToMap[K comparable, V any](collection []V, iteratee func(V) K) map[K]V
ToMap transforms a slice or an array of structs to a map based on a pivot callback.
func ToSlicePtr ΒΆ
func ToSlicePtr[T any](collection []T) []*T
ToPtr returns a slice of pointer copy of value.
func Uniq ΒΆ
func Uniq[T comparable](collection []T) []T
Uniq returns a duplicate-free version of an array, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array.
func UniqBy ΒΆ
func UniqBy[T any, U comparable](collection []T, iteratee func(T) U) []T
Uniq returns a duplicate-free version of an array, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array. It accepts `iteratee` which is invoked for each element in array to generate the criterion by which uniqueness is computed.
func Values ΒΆ
func Values[K comparable, V any](in map[K]V) []V
Values creates an array of the map values.
Types ΒΆ
type Entry ΒΆ
type Entry[K comparable, V any] struct { Key K Value V }
Entry defines a key/value pairs.
func Entries ΒΆ
func Entries[K comparable, V any](in map[K]V) []Entry[K, V]
Entries transforms a map into array of key/value pairs.
