diff --git a/iteration.go b/iteration.go index 64dc5a2..160fa90 100644 --- a/iteration.go +++ b/iteration.go @@ -31,18 +31,15 @@ func (s *Selection) EachWithBreak(f func(int, *Selection) bool) *Selection { // element in that selection starting at 0, and a *Selection that contains // only that element. func (s *Selection) Map(f func(int, *Selection) string) (result []string) { - for i, n := range s.Nodes { - result = append(result, f(i, newSingleSelection(n, s.document))) - } - - return result + return Map(s, f) } -// Generic version of Selection.Map, allowing any type to be returned. +// Map is the generic version of Selection.Map, allowing any type to be +// returned. func Map[E any](s *Selection, f func(int, *Selection) E) (result []E) { for i, n := range s.Nodes { result = append(result, f(i, newSingleSelection(n, s.document))) } return result -} \ No newline at end of file +}