lo

package module
v0.0.0-...-15a9106 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2023 License: Apache-2.0, BSD-2-Clause Imports: 1 Imported by: 15

Documentation

Overview

Code generated by go generate; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any[K comparable, V any](collection map[K]V, optDefaultValue ...V) (anyValue V)

Any returns the first element of the map or an optionally provided default value if the collection is empty (if no default value is provided, the zero value of the collection's element type is returned).

func Batch

func Batch(callbacks ...func()) func()

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

func Cond[T any](condition bool, trueValue, falseValue T) T

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

func Filter[V any](collection []V, predicate func(V) bool) []V

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 First

func First[T any](slice []T, optDefaultValue ...T) (firstElement T)

First returns the first element of the slice or an optionally provided default value if the collection is empty (if no default value is provided, the zero value of the collection's element type is returned).

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]struct{}

KeyOnlyBy transforms a slice or an array of structs to a map containing the keys based on a pivot callback.

func Keys

func Keys[K comparable, V any](in map[K]V) []K

Keys creates an array of the map keys.

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 NoVariadic

func NoVariadic[V, R any](f func(...V) R) func() R

NoVariadic turns a variadic function into a non-variadic one (variadic part empty).

func NoVariadic1

func NoVariadic1[T1, V, R any](f func(T1, ...V) R) func(T1) R

NoVariadic1 turns a variadic function with 1 additional parameters into a non-variadic one (variadic part empty).

func NoVariadic2

func NoVariadic2[T1, T2, V, R any](f func(T1, T2, ...V) R) func(T1, T2) R

NoVariadic2 turns a variadic function with 2 additional parameters into a non-variadic one (variadic part empty).

func NoVariadic3

func NoVariadic3[T1, T2, T3, V, R any](f func(T1, T2, T3, ...V) R) func(T1, T2, T3) R

NoVariadic3 turns a variadic function with 3 additional parameters into a non-variadic one (variadic part empty).

func NoVariadic4

func NoVariadic4[T1, T2, T3, T4, V, R any](f func(T1, T2, T3, T4, ...V) R) func(T1, T2, T3, T4) R

NoVariadic4 turns a variadic function with 4 additional parameters into a non-variadic one (variadic part empty).

func NoVariadic5

func NoVariadic5[T1, T2, T3, T4, T5, V, R any](f func(T1, T2, T3, T4, T5, ...V) R) func(T1, T2, T3, T4, T5) R

NoVariadic5 turns a variadic function with 5 additional parameters into a non-variadic one (variadic part empty).

func NoVariadic6

func NoVariadic6[T1, T2, T3, T4, T5, T6, V, R any](f func(T1, T2, T3, T4, T5, T6, ...V) R) func(T1, T2, T3, T4, T5, T6) R

NoVariadic6 turns a variadic function with 6 additional parameters into a non-variadic one (variadic part empty).

func NoVariadic7

func NoVariadic7[T1, T2, T3, T4, T5, T6, T7, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, ...V) R) func(T1, T2, T3, T4, T5, T6, T7) R

NoVariadic7 turns a variadic function with 7 additional parameters into a non-variadic one (variadic part empty).

func NoVariadic8

func NoVariadic8[T1, T2, T3, T4, T5, T6, T7, T8, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8) R

NoVariadic8 turns a variadic function with 8 additional parameters into a non-variadic one (variadic part empty).

func NoVariadic9

func NoVariadic9[T1, T2, T3, T4, T5, T6, T7, T8, T9, V, R any](f func(T1, T2, T3, T4, T5, T6, T7, T8, T9, ...V) R) func(T1, T2, T3, T4, T5, T6, T7, T8, T9) R

NoVariadic9 turns a variadic function with 9 additional parameters into a non-variadic one (variadic part empty).

func PanicOnErr

func PanicOnErr[T any](result T, err error) T

PanicOnErr panics of the seconds parameter is an error and returns the first parameter otherwise.

func Reduce

func Reduce[T any, R any](collection []T, accumulator func(R, T) R, initial R) R

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 Return1

func Return1[A any](a A, _ ...any) A

Return1 returns the first parameter out of a set of variadic arguments.

func Return2

func Return2[A any](_ any, a A, _ ...any) A

Return2 returns the second parameter out of a set of variadic arguments.

func Return3

func Return3[A any](_, _ any, a A, _ ...any) A

Return3 returns the third parameter out of a set of variadic arguments.

func Return4

func Return4[A any](_, _, _ any, a A, _ ...any) A

Return4 returns the 4th parameter out of a set of variadic arguments..

func Return5

func Return5[A any](_, _, _, _ any, a A, _ ...any) A

Return5 returns the 5th parameter out of a set of variadic arguments.

func Sum

func Sum[T constraints.Numeric](collection ...T) T

Sum returns the sum of the collection.

func Values

func Values[K comparable, V any](in map[K]V) []V

Values creates an array of the map values.

func Void

func Void[A, B any](f func(A) B) func(A)

Void returns a function that discards the return argument of the given function.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL