From 9696f7d42bc19b9db3d42cd4b40654d7b1ca22c4 Mon Sep 17 00:00:00 2001 From: Tordarus Date: Wed, 9 Feb 2022 12:17:54 +0100 Subject: [PATCH] added Flush function --- utils.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils.go b/utils.go index 43a3baa..8873523 100644 --- a/utils.go +++ b/utils.go @@ -1,10 +1,5 @@ package channel -import ( - "context" - "time" -) - func determineBufferSize[T any](channels []<-chan T) int { if len(channels) == 0 { return 0 @@ -16,3 +11,9 @@ func determineBufferSize[T any](channels []<-chan T) int { } return bufSize / len(channels) } + +// Flush consumes all values and discards them immediately +func Flush[T any](sources ...<-chan T) { + for range Merge(sources...) { + } +}