github.com/m4gshm/gollections@v0.0.10/map_/filter/api.go (about) 1 // Package filter provides helpers for filtering keys or values of a map 2 package filter 3 4 // Key adapts a key appliable predicate to a key\value one 5 func Key[V, K any](predicate func(K) bool) (out func(K, V) bool) { 6 if predicate != nil { 7 out = func(key K, val V) bool { return predicate(key) } 8 } 9 return 10 } 11 12 // Value adapts a value appliable predicate to a key\value one 13 func Value[K, V any](predicate func(V) bool) (out func(K, V) bool) { 14 if predicate != nil { 15 out = func(key K, val V) bool { return predicate(val) } 16 } 17 return 18 }