mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-10 16:55:40 +00:00
Changes "indexes" to "indices"
This commit is contained in:
parent
a1ac5b6df5
commit
ddbed76e45
@ -67,7 +67,8 @@ a: 1
|
|||||||
b: 2
|
b: 2
|
||||||
```
|
```
|
||||||
|
|
||||||
## from_entries with numeric key indexes
|
## from_entries with numeric key indices
|
||||||
|
|
||||||
from_entries always creates a map, even for numeric keys
|
from_entries always creates a map, even for numeric keys
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
|
|||||||
@ -27,7 +27,7 @@ myMap:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Pick indices from array
|
## Pick indices from array
|
||||||
Note that the order of the indexes matches the pick order and non existent indexes are skipped.
|
Note that the order of the indices matches the pick order and non existent indices are skipped.
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@ -36,7 +36,7 @@ var entriesOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "from_entries with numeric key indexes",
|
description: "from_entries with numeric key indices",
|
||||||
subdescription: "from_entries always creates a map, even for numeric keys",
|
subdescription: "from_entries always creates a map, even for numeric keys",
|
||||||
document: `[a,b]`,
|
document: `[a,b]`,
|
||||||
expression: `to_entries | from_entries`,
|
expression: `to_entries | from_entries`,
|
||||||
|
|||||||
@ -34,7 +34,7 @@ var pickOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Pick indices from array",
|
description: "Pick indices from array",
|
||||||
subdescription: "Note that the order of the indexes matches the pick order and non existent indexes are skipped.",
|
subdescription: "Note that the order of the indices matches the pick order and non existent indices are skipped.",
|
||||||
document: `[cat, leopard, lion]`,
|
document: `[cat, leopard, lion]`,
|
||||||
expression: `pick([2, 0, 734, -5])`,
|
expression: `pick([2, 0, 734, -5])`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
|
|||||||
@ -89,7 +89,7 @@ func traverseArrayOperator(d *dataTreeNavigator, context Context, expressionNode
|
|||||||
return Context{}, err
|
return Context{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// rhs is a collect expression that will yield indexes to retrieve of the arrays
|
// rhs is a collect expression that will yield indices to retrieve of the arrays
|
||||||
|
|
||||||
rhs, err := d.GetMatchingNodes(context.ReadOnlyClone(), expressionNode.RHS)
|
rhs, err := d.GetMatchingNodes(context.ReadOnlyClone(), expressionNode.RHS)
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ func traverseMap(context Context, matchingNode *CandidateNode, keyNode *yaml.Nod
|
|||||||
|
|
||||||
func doTraverseMap(newMatches *orderedmap.OrderedMap, candidate *CandidateNode, wantedKey string, prefs traversePreferences, splat bool) error {
|
func doTraverseMap(newMatches *orderedmap.OrderedMap, candidate *CandidateNode, wantedKey string, prefs traversePreferences, splat bool) error {
|
||||||
// value.Content is a concatenated array of key, value,
|
// value.Content is a concatenated array of key, value,
|
||||||
// so keys are in the even indexes, values in odd.
|
// so keys are in the even indices, values in odd.
|
||||||
// merge aliases are defined first, but we only want to traverse them
|
// merge aliases are defined first, but we only want to traverse them
|
||||||
// if we don't find a match directly on this node first.
|
// if we don't find a match directly on this node first.
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user