mcmp: rename GetSeries* functions to just Series*

This commit is contained in:
Brian Picciano 2019-06-15 17:52:55 -06:00
parent af836c1cab
commit dedf3a0368
4 changed files with 14 additions and 14 deletions

View File

@ -56,19 +56,19 @@ func AddSeriesValue(c *Component, key, value interface{}) {
c.SetValue(numValueElsKey, lastNumValueEls+1)
}
// GetSeriesElements returns the sequence of values that have been added to the
// SeriesElements returns the sequence of values that have been added to the
// Component under the given key via AddSeriesValue, interlaced with children
// which have been spawned from the Component, in the same respective order the
// events originally happened.
func GetSeriesElements(c *Component, key interface{}) []SeriesElement {
func SeriesElements(c *Component, key interface{}) []SeriesElement {
els, _ := getSeriesElements(c, key)
return els
}
// GetSeriesValues returns the sequence of values that have been added to the
// SeriesValues returns the sequence of values that have been added to the
// Component under the given key via AddSeriesValue, in the same order the
// values were added.
func GetSeriesValues(c *Component, key interface{}) []interface{} {
func SeriesValues(c *Component, key interface{}) []interface{} {
elsKey, numValueElsKey := seriesKeys(key)
els, _ := c.Value(elsKey).([]SeriesElement)
numValueEls, _ := c.Value(numValueElsKey).(int)

View File

@ -12,15 +12,15 @@ func TestSeries(t *T) {
// test empty state
c := new(Component)
massert.Require(t,
massert.Length(GetSeriesElements(c, key), 0),
massert.Length(GetSeriesValues(c, key), 0),
massert.Length(SeriesElements(c, key), 0),
massert.Length(SeriesValues(c, key), 0),
)
// test after a single value has been added
AddSeriesValue(c, key, 1)
massert.Require(t,
massert.Equal([]SeriesElement{{Value: 1}}, GetSeriesElements(c, key)),
massert.Equal([]interface{}{1}, GetSeriesValues(c, key)),
massert.Equal([]SeriesElement{{Value: 1}}, SeriesElements(c, key)),
massert.Equal([]interface{}{1}, SeriesValues(c, key)),
)
// test after a child has been added
@ -28,9 +28,9 @@ func TestSeries(t *T) {
massert.Require(t,
massert.Equal(
[]SeriesElement{{Value: 1}, {Child: childA}},
GetSeriesElements(c, key),
SeriesElements(c, key),
),
massert.Equal([]interface{}{1}, GetSeriesValues(c, key)),
massert.Equal([]interface{}{1}, SeriesValues(c, key)),
)
// test after another value has been added
@ -38,8 +38,8 @@ func TestSeries(t *T) {
massert.Require(t,
massert.Equal(
[]SeriesElement{{Value: 1}, {Child: childA}, {Value: 2}},
GetSeriesElements(c, key),
SeriesElements(c, key),
),
massert.Equal([]interface{}{1, 2}, GetSeriesValues(c, key)),
massert.Equal([]interface{}{1, 2}, SeriesValues(c, key)),
)
}

View File

@ -29,7 +29,7 @@ func triggerHooks(
key interface{},
next func([]mcmp.SeriesElement) (mcmp.SeriesElement, []mcmp.SeriesElement),
) error {
els := mcmp.GetSeriesElements(cmp, hookKey{key})
els := mcmp.SeriesElements(cmp, hookKey{key})
var el mcmp.SeriesElement
for {
if len(els) == 0 {

View File

@ -21,7 +21,7 @@ func Component() *mcmp.Component {
mlog.SetLogger(cmp, logger)
mrun.InitHook(cmp, func(context.Context) error {
envVals := mcmp.GetSeriesValues(cmp, envCmpKey(0))
envVals := mcmp.SeriesValues(cmp, envCmpKey(0))
env := make([]string, 0, len(envVals))
for _, val := range envVals {
tup := val.([2]string)