Documentation ¶
Index ¶
- Constants
- func Buffer[A any](size int, in <-chan A, options ...Option) ([]A, bool)
- func Collect[A any](c <-chan A, options ...Option) []A
- func Compact[A any](c <-chan A, equal func(a, b A) bool, options ...Option) <-chan A
- func CompactWith[A any](options ...Option) func(c <-chan A, equal func(a, b A) bool) <-chan A
- func Concat[A any](cs ...<-chan A) <-chan A
- func ConcatWith[A any](options ...Option) func(cs ...<-chan A) <-chan A
- func Done[T any](c chan T) <-chan struct{}
- func Drop[A any](c <-chan A, i int, options ...Option) <-chan A
- func DropAll[A any](c <-chan A, async bool)
- func DropBuffer[A any](c <-chan A, async bool)
- func DropWhile[A any](c <-chan A, drop func(a A) bool, options ...Option) <-chan A
- func DropWhileWith[A any](options ...Option) func(c <-chan A, drop func(a A) bool) <-chan A
- func DropWith[A any](options ...Option) func(c <-chan A, i int) <-chan A
- func EveryDone[T any](done ...<-chan T) <-chan T
- func FanIn[A any](cs ...<-chan A) <-chan A
- func FanInWith[A any](options ...Option) func(cs ...<-chan A) <-chan A
- func FanOut[A any](c <-chan A, size int, options ...Option) []<-chan A
- func FanOutWith[A any](options ...Option) func(c <-chan A, size int) []<-chan A
- func Filter[A any](c <-chan A, include func(a A) bool, options ...Option) <-chan A
- func FilterWith[A any](options ...Option) func(c <-chan A, include func(a A) bool) <-chan A
- func Flatten[A any](in <-chan []A, options ...Option) <-chan A
- func FlattenWith[A any](options ...Option) func(in <-chan []A) <-chan A
- func Generate[A any](elements ...A) <-chan A
- func GenerateWith[A any](options ...Option) func(elements ...A) <-chan A
- func Generator[A any](gen func(func(A)), options ...Option) <-chan A
- func GeneratorWith[A any](options ...Option) func(gen func(func(A))) <-chan A
- func Map[A any, B any](in <-chan A, mapper func(a A) B, options ...Option) <-chan B
- func MapWith[A any, B any](options ...Option) func(in <-chan A, mapper func(a A) B) <-chan B
- func Partition[A any](c <-chan A, predicate func(a A) bool, options ...Option) (satisfied, notSatisfied <-chan A)
- func PartitionWith[A any](options ...Option) func(c <-chan A, predicate func(a A) bool) (satisfied, notSatisfied <-chan A)
- func Peek[A any](in <-chan A, apply func(a A), options ...Option) <-chan A
- func PeekWith[A any](options ...Option) func(in <-chan A, apply func(a A)) <-chan A
- func ReadFrom[A any](c chan A, mode int) func() (m A, ok bool)
- func Readers[A any](chans ...chan A) []<-chan A
- func SomeDone[T any](done ...<-chan T) <-chan T
- func Take[A any](c <-chan A, i int, options ...Option) <-chan A
- func TakeBuffer[A any](c <-chan A) []A
- func TakeWhile[A any](c <-chan A, take func(a A) bool, options ...Option) <-chan A
- func TakeWhileWith[A any](options ...Option) func(c <-chan A, take func(a A) bool) <-chan A
- func TakeWith[A any](option ...Option) func(c <-chan A, i int) <-chan A
- func Unzip[A any, B any, C any](zipped <-chan C, unzipper func(c C) (A, B), options ...Option) (<-chan A, <-chan B)
- func WriteTo[A any](c chan<- A, mode int) func(m A)
- func Writers[A any](chans ...chan A) []chan<- A
- func Zip[A any, B any, C any](ac <-chan A, bc <-chan B, zipper func(a A, b B) C, options ...Option) <-chan C
- type Option
Constants ¶
const ( WriteSync = iota WriteAync WriteIfFree )
const ( ReadWait = iota ReadIfWaiting = iota )
Variables ¶
This section is empty.
Functions ¶
func Collect ¶
Collect will collect all enteries in a channel into a slice and return it. It stops and returns when done or c is closed It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func Compact ¶
Compact takes a chan and applies the "equal" func to every item and its predecessor. If it returns true, the current item being the same as the previous item, the current one will not be includes on the output chan The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func CompactWith ¶
CompactWith takes a chan and applies the "equal" func to every item and its predecessor. If it returns true, the current item being the same as the previous item, the current one will not be includes on the output chan The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func Concat ¶
func Concat[A any](cs ...<-chan A) <-chan A
Concat takes a slice of chans and put all items received on the returning chan
func ConcatWith ¶
ConcatWith takes a slice of chans and put all items received on the returning chan The input chans are read until closed in order. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func Done ¶
func Done[T any](c chan T) <-chan struct{}
Done takes a channel, c, that is ment to indicate that something is done and returns a chan struct{} that closes once c does It is ment to convert a channel of any type to a channel that aligns with context.Context.Done() if data is passed on c, Done will drain it
func Drop ¶
Drop takes a chan and returns a chan. It will drop the first "i" items read from the in chan and write the remaining items onto the return chan. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func DropAll ¶
DropAll will consume a channel until it closes. If async is false, it will block until the channel is closed and all entries are consumed. If async is true it will immediately return and consume all elements in the background
func DropBuffer ¶
DropBuffer will drop everything in the channels buffer ()
func DropWhile ¶
DropWhile takes a chan and returns a chan. It will drop items until the drop function returns false, and will then write the remaining items onto the return chan. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func DropWhileWith ¶
DropWhileWith takes a chan and returns a chan. It will drop items until the drop function returns false, and will then write the remaining items onto the return chan. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func DropWith ¶
DropWith takes a chan and returns a chan. It will drop the first "i" items read from the in chan and write the remaining items onto the return chan. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func EveryDone ¶
func EveryDone[T any](done ...<-chan T) <-chan T
EveryDone returns a channel that closes when all channels from the input arguments are closed
func FanIn ¶
func FanIn[A any](cs ...<-chan A) <-chan A
FanIn will merge all input from input channels into one output channel. It differs from Flattenin that it reads from all channels concurrently instead of synchronized
func FanInWith ¶
FanInWith will merge all input from input channels into one output channel. It differs from FlattenUntil in that it reads from all channels concurrently instead of synchronized The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func FanOut ¶
FanOut will return a slice of chans on which entries read from the input chan are written to every output chan. A new entry won't be read from the input chan until all output chans has consumed entry, if the buffer is full. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func FanOutWith ¶
FanOutWith will return a slice of chans on which entries read from the input chan are written to every output chan. A new entry won't be read from the input chan until all output chans has consumed entry, if the buffer is full. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func Filter ¶
Filter takes a chan and applies the "include" func to every item. If it returns true, the item is out on the output chan The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func FilterWith ¶
FilterWith takes a chan and applies the "include" func to every item. If it returns true, the item is out on the output chan The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func Flatten ¶
Flatten takes a chan of a slice put all items received on the returning chan, one by one The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func FlattenWith ¶
func Generate ¶
func Generate[A any](elements ...A) <-chan A
Generate takes a slice of elements, returns a channel and writes the elements to the channel. It closes once all elements in the slice are written The return chan has a buffer of 0
func GenerateWith ¶
func GeneratorWith ¶
func Map ¶
Map will take a chan, in, and executes mapper and put the resulting on to the return chan. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func MapWith ¶
MapWith will take a chan, in, and executes mapper and put the resulting on to the return chan. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func Partition ¶
func Partition[A any](c <-chan A, predicate func(a A) bool, options ...Option) (satisfied, notSatisfied <-chan A)
Partition takes a chan and returns two chans. For every item consumed it is passed through the predicate func. If it returns true, the item is put on the satisfied chan otherwise it is put on the notSatisfied chan The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func PartitionWith ¶
func PartitionWith[A any](options ...Option) func(c <-chan A, predicate func(a A) bool) (satisfied, notSatisfied <-chan A)
PartitionWith takes a chan and returns two chans. For every item consumed it is passed through the predicate func. If it returns true, the item is put on the satisfied chan otherwise it is put on the notSatisfied chan The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func Peek ¶
Peek will take a chan, in, and executes apply on every element and then writes the element to the return chan. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func PeekWith ¶
PeekWith will take a chan, in, and executes apply on every element and then writes the element to the return chan. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func Readers ¶
func Readers[A any](chans ...chan A) []<-chan A
Readers takes a slice of chans and returns the reader version of it
func SomeDone ¶
func SomeDone[T any](done ...<-chan T) <-chan T
SomeDone returns a channel that closes as soon as any channels from the input arguments are closed
func Take ¶
Take takes a chan and returns a chan. It will write the first "i" items read from the in chan onto the return chan and then close the read chan. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func TakeBuffer ¶
func TakeBuffer[A any](c <-chan A) []A
TakeBuffer will take everything in the channels buffer ()
func TakeWhile ¶
TakeWhile takes a chan and returns a chan. It will write all items read from the in chan onto the return chan until the take function returns false, then the out chan will close The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func TakeWhileWith ¶
TakeWhileWith takes a chan and returns a chan. It will write all items read from the in chan onto the return chan until the take function returns false, then the out chan will close The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func TakeWith ¶
TakeWith takes a chan and returns a chan. It will write the first "i" items read from the in chan onto the return chan and then close the read chan. The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option
func Unzip ¶
func Unzip[A any, B any, C any](zipped <-chan C, unzipper func(c C) (A, B), options ...Option) (<-chan A, <-chan B)
Unzip takes one chan and returns a chan. It will read a C item from the input chan, apply the unzipper to the two resulting items on the output chans The return chan has a buffer of buffer size supplied in input args. It will stop once the any in chan are closed, done is closed
func Writers ¶
func Writers[A any](chans ...chan A) []chan<- A
Writers takes a slice of chans and returns the writer version of it
func Zip ¶
func Zip[A any, B any, C any](ac <-chan A, bc <-chan B, zipper func(a A, b B) C, options ...Option) <-chan C
Zip takes two chans and returns a chan. it will read a A item and a B item. Apply the zipper to these and output the result on the returning chan The return chan has a buffer of buffer size supplied in input Option, default is 0. It will stop once "in", "done" channel is closed or the context.Done is closed, which is supplied in Option