Documentation
¶
Index ¶
- func Contains[K comparable](values []K, value K) bool
- func Every[T any](elements []T, compare func(element T, index int) bool) (ok bool)
- func Filter[K any](values []K, fn func(value K, index int) bool) []K
- func Find[T any](elements []T, compare func(element T, index int) bool) (T, bool)
- func FindIndex[T any](elements []T, compare func(element T, index int) bool) int
- func ForEach[K any](values []K, fn func(value K, index int))
- func GroupBy[T any, K comparable](values []T, iteratee func(value T, index int) K) map[K][]T
- func Includes[K comparable](values []K, value K) bool
- func IndexOf[T comparable](collection []T, value T) int
- func Join[K any](values []K, seperator string, fn ...func(value K, index int) string) (string, error)
- func Last[T any](collection []T) T
- func LastIndexOf[T comparable](collection []T, value T) int
- func Map[K any, R any](values []K, fn func(value K, index int) R) []R
- func Max[T Number](collection []T) T
- func Min[T Number](collection []T) T
- func Reduce[K any, R any](values []K, fn func(all R, value K, index int) R, initialValue R) R
- func Repeat[T any](count int, value T) []T
- func Reverse[T any](collection []T) []T
- func Shuffle[T any](collection []T) []T
- func Some[T any](elements []T, compare func(element T, index int) bool) (ok bool)
- func Sort[T any](collection []T, cmp func(v1 T, v2 T) bool) []T
- func UniqueBy[T any, U comparable](collection []T, iteratee func(value T, index int) U) []T
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶ added in v1.4.7
func Contains[K comparable](values []K, value K) bool
Contains returns true if the array contains the value. It is a wrapper for the `Includes` function.
func Find ¶
Find searches an element in a slice based on a predicated. It returns element and true if element was found.
func FindIndex ¶ added in v1.0.1
FindIndex returns the index of the first occurrence of value in collection. If value is not present in collection, then FindIndex returns -1.
func GroupBy ¶
func GroupBy[T any, K comparable](values []T, iteratee func(value T, index int) K) map[K][]T
GroupBy ...
func Includes ¶
func Includes[K comparable](values []K, value K) bool
Includes returns true if the array contains the value.
func IndexOf ¶ added in v1.0.1
func IndexOf[T comparable](collection []T, value T) int
IndexOf returns the index of the first occurrence of value in collection. If value is not present in collection, then IndexOf returns -1.
func Join ¶ added in v1.4.7
func Join[K any](values []K, seperator string, fn ...func(value K, index int) string) (string, error)
Join joins all elements of the array into a string.
func Last ¶ added in v1.0.1
func Last[T any](collection []T) T
Last returns the last element of collection. If collection is empty, then Last returns nil.
func LastIndexOf ¶ added in v1.0.1
func LastIndexOf[T comparable](collection []T, value T) int
LastIndexOf returns the index of the last occurrence of value in collection. If value is not present in collection, then LastIndexOf returns -1.
func Map ¶
Map applies the function fn to each value in the array and returns a new array with the results.
func Max ¶ added in v1.0.1
func Max[T Number](collection []T) T
Max returns the maxium value in collection.
func Min ¶ added in v1.0.1
func Min[T Number](collection []T) T
Min returns the minimum value in collection.
func Reduce ¶
Reduce returns the result of applying the function fn to each value in the array and an accumulator, starting with the initial value.
func Reverse ¶ added in v1.0.1
func Reverse[T any](collection []T) []T
Reverse returns an array of reversed values.
func Shuffle ¶ added in v1.0.1
func Shuffle[T any](collection []T) []T
Shuffle returns an array of shuffled values. Use the Fisher-Yates shuffle algorithm.
func UniqueBy ¶ added in v1.0.1
func UniqueBy[T any, U comparable](collection []T, iteratee func(value T, index int) U) []T
UniqueBy returns an array of unique values by given filter function.