mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-07 14:25:38 +00:00
Updated unique docs
This commit is contained in:
parent
1425d0720e
commit
689c535a29
@ -1,3 +1,4 @@
|
|||||||
# Unique
|
# Unique
|
||||||
|
|
||||||
This is used to filter out duplicated items in an array.
|
This is used to filter out duplicated items in an array. Note that the original order of the array is maintained.
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,12 @@ Note that versions prior to 4.18 require the 'eval/e' command to be specified.&#
|
|||||||
{% endhint %}
|
{% endhint %}
|
||||||
|
|
||||||
## Unique array of scalars (string/numbers)
|
## Unique array of scalars (string/numbers)
|
||||||
|
Note that unique maintains the original order of the array.
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
- 1
|
|
||||||
- 2
|
- 2
|
||||||
|
- 1
|
||||||
- 3
|
- 3
|
||||||
- 2
|
- 2
|
||||||
```
|
```
|
||||||
@ -22,8 +24,8 @@ yq 'unique' sample.yml
|
|||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
- 1
|
|
||||||
- 2
|
- 2
|
||||||
|
- 1
|
||||||
- 3
|
- 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -7,10 +7,11 @@ import (
|
|||||||
var uniqueOperatorScenarios = []expressionScenario{
|
var uniqueOperatorScenarios = []expressionScenario{
|
||||||
{
|
{
|
||||||
description: "Unique array of scalars (string/numbers)",
|
description: "Unique array of scalars (string/numbers)",
|
||||||
document: `[1,2,3,2]`,
|
subdescription: "Note that unique maintains the original order of the array.",
|
||||||
|
document: `[2,1,3,2]`,
|
||||||
expression: `unique`,
|
expression: `unique`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[], (!!seq)::- 1\n- 2\n- 3\n",
|
"D0, P[], (!!seq)::- 2\n- 1\n- 3\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user