chans

package
v0.0.0-...-b7aacc1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Concat

func Concat[T any](channels ...<-chan T) <-chan T

Concat produces a channel containing all items from all channels concatenated in the order they are passed.

func Drain

func Drain[T any](channel <-chan T) int

Drain enumerates all items from the channel and discards them. Blocks until the channel is closed and returns number of items drained.

func DrainOpen

func DrainOpen[T any](channel <-chan T) int

DrainOpen enumerates all items from the channel and discards them. Returns number of items drained as soon as channel is empty.

func Empty

func Empty[T any]() <-chan T

Empty returns an empty chanel

func Filter

func Filter[T any](source <-chan T, predicate func(T) bool) <-chan T

Filter returns a new channel that only contains elements that match the predicate. Runs until source channel is closed

func Flatten

func Flatten[T any](source <-chan <-chan T) <-chan T

Flatten flattens a chan of chans into a chan of elements

func ForEach

func ForEach[T any](source <-chan T, f func(T))

ForEach performs the given function on every element in the channel. Runs until source channel is closed

func FromValues

func FromValues[T any](values ...T) <-chan T

FromValues creates a ComposableChannel from a list of values

func Map

func Map[T, S any](source <-chan T, f func(T) S, capacity ...int) <-chan S

Map maps a channel of T to a channel of S. Runs until source channel is closed. By default, output channel has the same capacity as the source channel. Desired capacity of the output channel can be specified via an optional argument.

func Pop

func Pop[T any](ctx context.Context, c <-chan T) (T, bool)

Pop gets the next element from the given channel. Returns false if the context expires before an element is available.

func Push

func Push[T any](ctx context.Context, c chan<- T, x T) bool

Push adds the given element to the given channel. Returns false if the context expires before the channel unblocks.

func Range

func Range[T constraints.Integer](from, to T) <-chan T

Range creates a channel that inclusively contains all values from `from` to `to`.

func RangeBig

func RangeBig(from, to *big.Int) <-chan *big.Int

RangeBig creates a channel that inclusively contains all values from `from` to `to`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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