added generic types + FilterChanges

This commit is contained in:
2025-06-26 15:22:42 +02:00
parent 21430b0d65
commit 9990d7206d
7 changed files with 48 additions and 20 deletions

18
types.go Normal file
View File

@ -0,0 +1,18 @@
package channel
func DefaultEqualityComparator[T comparable](a, b T) bool {
return a == b
}
type EqualityComparator[T any] = func(a, b T) bool
type FilterFunc[T any] = func(T) bool
type Consumer[T any] = func(T)
type IndexedConsumer[T any] = func(int, T)
type Mapper[I, O any] = func(I) O
type ErrorMapper[I, O any] = func(I) (O, error)
type MapMapper[T any, K comparable, V any] = func(T) (K, V)
type MapUnmapper[K comparable, V, T any] = func(K, V) T
type Reducer[A, T any] = func(acc A, value T) A