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.
(f func(int, *Selection) bool)
| 31 | // out of the loop by returning false in the callback function. It returns the |
| 32 | // current Selection object. |
| 33 | func (s *Selection) EachWithBreak(f func(int, *Selection) bool) *Selection { |
| 34 | for i, n := range s.Nodes { |
| 35 | if !f(i, newSingleSelection(n, s.document)) { |
| 36 | return s |
| 37 | } |
| 38 | } |
| 39 | return s |
| 40 | } |
| 41 | |
| 42 | // Map passes each element in the current matched set through a function, |
| 43 | // producing a slice of string holding the returned values. The function |