Skip to content

Commit

Permalink
Merge f52c7b6 into 61d6df4
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW authored Oct 23, 2022
2 parents 61d6df4 + f52c7b6 commit eb099b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,27 @@ func (o *operator) Close() {

func (o *operator) record(v map[string]interface{}) {
if o.useMap {
o.recortAsMapped(v)
o.recordAsMapped(v)
return
}
o.recortAsListed(v)
o.recordAsListed(v)
}

func (o *operator) recortAsListed(v map[string]interface{}) {
func (o *operator) recordAsListed(v map[string]interface{}) {
if o.store.loopIndex != nil && *o.store.loopIndex > 0 {
// delete values of prevous loop
o.store.steps = o.store.steps[:len(o.store.steps)-1]
}
o.store.recortAsListed(v)
o.store.recordAsListed(v)
}

func (o *operator) recortAsMapped(v map[string]interface{}) {
func (o *operator) recordAsMapped(v map[string]interface{}) {
if o.store.loopIndex != nil && *o.store.loopIndex > 0 {
// delete values of prevous loop
delete(o.store.stepMap, o.steps[len(o.store.stepMap)-1].key)
}
k := o.steps[len(o.store.stepMap)].key
o.store.recortAsMapped(k, v)
o.store.recordAsMapped(k, v)
}

func (o *operator) ids() []string {
Expand Down
8 changes: 4 additions & 4 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ type store struct {
latestMapKey string
}

func (s *store) recortAsMapped(k string, v map[string]interface{}) {
func (s *store) recordAsMapped(k string, v map[string]interface{}) {
if !s.useMap {
panic("recortAsMapped can only be used if useMap = true")
panic("recordAsMapped can only be used if useMap = true")
}
s.stepMap[k] = v
s.latestMapKey = k
}

func (s *store) recortAsListed(v map[string]interface{}) {
func (s *store) recordAsListed(v map[string]interface{}) {
if s.useMap {
panic("recortAsMapped can only be used if useMap = false")
panic("recordAsMapped can only be used if useMap = false")
}
s.steps = append(s.steps, v)
}
Expand Down

0 comments on commit eb099b2

Please sign in to comment.