f

package
v0.35.3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscardCh

func DiscardCh[T any](ch <-chan T)

DiscardCh consumes all incoming messages from the given channel until it's closed.

func Filter

func Filter[T any](values []T, matcher Matcher[T]) []T

Filter takes a slice of type []T and a Matcher[T]. It returns a newly allocated slice containing only those elements of the input slice that satisfy the matcher.

func Map

func Map[T, U any](values []T, mapper Mapper[T, U]) []U

Map applies the Mapper function to each element of the slice and returns a new slice with the results in the same order.

func Reduce

func Reduce[T any](values []T, reducer Reducer[T]) T

Reduce applies the Reducer function to all elements of the input values and returns the result.

Types

type Future

type Future[T any] interface {
	Send(T)
	Await() T
}

Future is an object that holds a result value. The value may be read and written asynchronously.

func NewFuture

func NewFuture[T any]() Future[T]

NewFuture creates a new Future[T]

type Mapper

type Mapper[T, U any] func(T) U

Mapper is a function that converts a value of one type to another type.

type Matcher

type Matcher[T any] func(T) bool

Matcher is a function that tests if a given value match a certain criteria.

func Equals

func Equals[T comparable](value T) Matcher[T]

Equals return a Matcher that matches the given value

func NotEquals

func NotEquals[T comparable](value T) Matcher[T]

NotEquals return a Matcher that does not match the given value

type Reducer

type Reducer[T any] func(T, T) T

Reducer is a function that combines two values of the same type and return the combined value.

Jump to

Keyboard shortcuts

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