add MapIter2 for iterating over iter.Seq2 values
1 file changed, 13 insertions(+), 0 deletions(-)
changed files
M gomponents.go → gomponents.go
@@ -291,6 +291,19 @@ }, } } +// Map an iterator of pairs of values to an IterNode (which is just an [iter.Seq] of [Node]-s) +func MapIter2[K, V any](ts iter.Seq2[K, V], cb func(K, V) Node) IterNode { + return IterNode{ + func(yield func(Node) bool) { + for k, v := range ts { + if !yield(cb(k, v)) { + return + } + } + }, + } +} + type IterNode struct { iter.Seq[Node] }