MCPcopy Create free account
hub / github.com/PuerkitoBio/goquery / Eq

Method Eq

array.go:35–45  ·  view source on GitHub ↗

Eq reduces the set of matched elements to the one at the specified index. If a negative index is given, it counts backwards starting at the end of the set. It returns a new Selection object, and an empty Selection object if the index is invalid.

(index int)

Source from the content-addressed store, hash-verified

33// set. It returns a new Selection object, and an empty Selection object if the
34// index is invalid.
35func (s *Selection) Eq(index int) *Selection {
36 if index < 0 {
37 index += len(s.Nodes)
38 }
39
40 if index >= len(s.Nodes) || index < 0 {
41 return pushStack(s, nil)
42 }
43
44 return s.Slice(index, index+1)
45}
46
47// Slice reduces the set of matched elements to a subset specified by a range
48// of indices. The start index is 0-based and indicates the index of the first

Callers 15

FirstMethod · 0.95
LastMethod · 0.95
TestForRangeFunction · 0.80
assertSelectionIsFunction · 0.80
TestRemoveClassSimilarFunction · 0.80
TestEqFunction · 0.80
TestEqNegativeFunction · 0.80
TestEqEmptyFunction · 0.80
TestEqInvalidFunction · 0.80
TestEqInvalidPositiveFunction · 0.80
TestEqInvalidNegativeFunction · 0.80

Calls 2

SliceMethod · 0.95
pushStackFunction · 0.85

Tested by 15

TestForRangeFunction · 0.64
assertSelectionIsFunction · 0.64
TestRemoveClassSimilarFunction · 0.64
TestEqFunction · 0.64
TestEqNegativeFunction · 0.64
TestEqEmptyFunction · 0.64
TestEqInvalidFunction · 0.64
TestEqInvalidPositiveFunction · 0.64
TestEqInvalidNegativeFunction · 0.64
TestEqRollbackFunction · 0.64
TestEqOutOfRangeRollbackFunction · 0.64