Updated unique docs

This commit is contained in:
Mike Farah 2022-04-29 12:16:57 +10:00
parent 1425d0720e
commit 689c535a29
4 changed files with 17 additions and 13 deletions

View File

@ -1,3 +1,4 @@
# 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.

View File

@ -9,10 +9,12 @@ Note that versions prior to 4.18 require the 'eval/e' command to be specified.&#
{% endhint %}
## Unique array of scalars (string/numbers)
Note that unique maintains the original order of the array.
Given a sample.yml file of:
```yaml
- 1
- 2
- 1
- 3
- 2
```
@ -22,8 +24,8 @@ yq 'unique' sample.yml
```
will output
```yaml
- 1
- 2
- 1
- 3
```

View File

@ -7,10 +7,11 @@ import (
var uniqueOperatorScenarios = []expressionScenario{
{
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`,
expected: []string{
"D0, P[], (!!seq)::- 1\n- 2\n- 3\n",
"D0, P[], (!!seq)::- 2\n- 1\n- 3\n",
},
},
{

View File

@ -1,10 +1,10 @@
4.25.1:
- Can specify a split expression file #1194
- Fixed append map bug when key matches value in existing map #1200
- Nicer error message when trying to use merge anchor tags other than maps #1184
- Fixed Don't automatically read stdin when the null input flag is used
- Added type as an alias for tag #1195
- Fixes bug when using write in-place with no expression and multiple files #1193
- Can specify a split expression file #1194
- Fixed append map bug when key matches value in existing map #1200
- Nicer error message when trying to use merge anchor tags other than maps #1184
- Fixed Don't automatically read stdin when the null input flag is used
- Added type as an alias for tag #1195
- Fixes bug when using write in-place with no expression and multiple files #1193
4.24.5:
- Fixed scenarios that dropped the first line if it's a comment (#1181)