MCPcopy
hub / github.com/PuerkitoBio/goquery / EachWithBreak

Method EachWithBreak

iteration.go:33–40  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

31// out of the loop by returning false in the callback function. It returns the
32// current Selection object.
33func (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

Callers 2

TestEachWithBreakFunction · 0.80
BenchmarkEachWithBreakFunction · 0.80

Calls 1

newSingleSelectionFunction · 0.85

Tested by 2

TestEachWithBreakFunction · 0.64
BenchmarkEachWithBreakFunction · 0.64