about summary refs log tree commit diff stats
path: root/gomponents_generic.go
blob: 6e6500b201db06219c39c45a0b03d4b64ed24d02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
//go:build go1.18
// +build go1.18

package gomponents

// Map a slice of anything to a slice of Nodes.
func Map[T any](ts []T, cb func(T) Node) []Node {
	var nodes []Node
	for _, t := range ts {
		nodes = append(nodes, cb(t))
	}
	return nodes
}