MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / SetFromArray

Function SetFromArray

channels/set.go:65–81  ·  view source on GitHub ↗

Creates a new Set from an array of strings. Returns an error if any names are invalid.

(names []string, mode StarMode)

Source from the content-addressed store, hash-verified

63
64// Creates a new Set from an array of strings. Returns an error if any names are invalid.
65func SetFromArray(names []string, mode StarMode) (base.Set, error) {
66 for _, name := range names {
67 if !IsValidChannel(name) {
68 return nil, illegalChannelError(name)
69 }
70 }
71 result := base.SetFromArray(names)
72 switch mode {
73 case RemoveStar:
74 result = result.Removing(UserStarChannel)
75 case ExpandStar:
76 if result.Contains(UserStarChannel) {
77 result = base.SetOf(UserStarChannel)
78 }
79 }
80 return result, nil
81}
82
83// SetOf creates a new Set. Returns an error if any names are invalid.
84func SetOf(chans ...ID) (Set, error) {

Callers 10

updateChannelsMethod · 0.92
channelsExpandedSetMethod · 0.92
getChannelsAndAccessMethod · 0.92
NewSyncRunnerWithLoggingFunction · 0.70
compileAccessMapFunction · 0.70
TestSetFromArrayFunction · 0.70
TestSetFromArrayWithStarFunction · 0.70
TestSetFromArrayErrorFunction · 0.70
UnmarshalJSONMethod · 0.70
BaseSetOfFunction · 0.70

Calls 6

SetFromArrayFunction · 0.92
SetOfFunction · 0.92
IsValidChannelFunction · 0.85
illegalChannelErrorFunction · 0.85
RemovingMethod · 0.80
ContainsMethod · 0.65

Tested by 3

TestSetFromArrayFunction · 0.56
TestSetFromArrayWithStarFunction · 0.56
TestSetFromArrayErrorFunction · 0.56