mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 14:14:52 +08:00
Added any_c and all_c operators
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
package yqlib
|
||||
|
||||
import (
|
||||
"github.com/elliotchance/orderedmap"
|
||||
"container/list"
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
"fmt"
|
||||
|
||||
"github.com/elliotchance/orderedmap"
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func unique(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
||||
@@ -19,7 +20,6 @@ func uniqueBy(d *dataTreeNavigator, context Context, expressionNode *ExpressionN
|
||||
log.Debugf("-- uniqueBy Operator")
|
||||
var results = list.New()
|
||||
|
||||
|
||||
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
|
||||
candidate := el.Value.(*CandidateNode)
|
||||
candidateNode := unwrapDoc(candidate.Node)
|
||||
@@ -27,7 +27,7 @@ func uniqueBy(d *dataTreeNavigator, context Context, expressionNode *ExpressionN
|
||||
if candidateNode.Kind != yaml.SequenceNode {
|
||||
return Context{}, fmt.Errorf("Only arrays are supported for unique")
|
||||
}
|
||||
|
||||
|
||||
var newMatches = orderedmap.NewOrderedMap()
|
||||
for _, node := range candidateNode.Content {
|
||||
child := &CandidateNode{Node: node}
|
||||
@@ -56,4 +56,4 @@ func uniqueBy(d *dataTreeNavigator, context Context, expressionNode *ExpressionN
|
||||
|
||||
return context.ChildContext(results), nil
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user