util

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSourceNotArray = errors.New("source value is not an array")
	ErrReducerNil     = errors.New("reducer function cannot be nil")
	ErrReducerNotFunc = errors.New("reducer argument must be a function")
)

Functions

func Any

func Any(vs []string, f func(any) bool) bool

Any returns true if one of the strings in the slice satisfies the predicate f.

func ConvertStringMapToAny

func ConvertStringMapToAny(m map[string]string) map[string]any

ConvertStringMapToAny converts a map of string elements to a map of any elements

func Filter

func Filter(vs []string, f func(string) bool) []string

Filter returns a new slice containing all strings in the slice that satisfy the predicate f.

func GetMapKeys

func GetMapKeys[K comparable, V any](m map[K]V) []K

GetMapKeys returns the keys of a map

func GetMapValues

func GetMapValues[K comparable, V any](m map[K]V) []V

GetMapKeys returns the keys of a map

func JSONEncode

func JSONEncode(v any) (string, error)

JSONEncode encodes a value to JSON

func Map

func Map(vs []string, f func(string) string) []string

Map returns a new slice containing the results of applying the function f to each string in the original slice.

func MergeMaps

func MergeMaps[K comparable, V any](maps ...map[K]V) map[K]V

MergeMaps merges two maps

func Reduce

func Reduce(source, initialValue, reducer any) (any, error)

Reduce an array of something into another thing

Types

This section is empty.

Jump to

Keyboard shortcuts

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