-
Notifications
You must be signed in to change notification settings - Fork 738
/
sid.go
30 lines (27 loc) · 928 Bytes
/
sid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package gpp
import (
gpplib "github.com/prebid/go-gpp"
gppConstants "github.com/prebid/go-gpp/constants"
)
// IsSIDInList returns true if the 'sid' value is found in the gppSIDs array. Its logic is used in more than
// one place in our codebase, therefore it was decided to make it its own function.
func IsSIDInList(gppSIDs []int8, sid gppConstants.SectionID) bool {
for _, id := range gppSIDs {
if id == int8(sid) {
return true
}
}
return false
}
// IndexOfSID returns a zero or non-negative integer that represents the position of
// the 'sid' value in the 'gpp.SectionTypes' array. If the 'sid' value is not found,
// returns -1. This logic is used in more than one place in our codebase, therefore
// it was decided to make it its own function.
func IndexOfSID(gpp gpplib.GppContainer, sid gppConstants.SectionID) int {
for i, id := range gpp.SectionTypes {
if id == sid {
return i
}
}
return -1
}