mirror of https://github.com/dexidp/dex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.1 KiB
33 lines
1.1 KiB
package goquery |
|
|
|
// Each iterates over a Selection object, executing a function for each |
|
// matched element. It returns the current Selection object. |
|
func (s *Selection) Each(f func(int, *Selection)) *Selection { |
|
for i, n := range s.Nodes { |
|
f(i, newSingleSelection(n, s.document)) |
|
} |
|
return s |
|
} |
|
|
|
// EachWithBreak iterates over a Selection object, executing a function for each |
|
// matched element. It is identical to Each except that it is possible to break |
|
// out of the loop by returning false in the callback function. It returns the |
|
// current Selection object. |
|
func (s *Selection) EachWithBreak(f func(int, *Selection) bool) *Selection { |
|
for i, n := range s.Nodes { |
|
if !f(i, newSingleSelection(n, s.document)) { |
|
return s |
|
} |
|
} |
|
return s |
|
} |
|
|
|
// Map passes each element in the current matched set through a function, |
|
// producing a slice of string holding the returned values. |
|
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 |
|
}
|
|
|