Skip to content

Conformance Examples 0.1.0 — Transforms: transform-uniq

uniq-strings

Duplicate string elements are removed, keeping the first occurrence's order.

Template

{{ xs | uniq }}

Context

{
    "xs": [
        "a",
        "b",
        "a",
        "c",
        "b"
    ]
}

Output

["a","b","c"]

uniq-numbers

Duplicate numeric elements are removed.

Template

{{ xs | uniq }}

Context

{
    "xs": [
        1,
        1,
        2,
        3,
        3
    ]
}

Output

[1,2,3]

uniq-non-list-is-null

uniq operates only on lists; a string input yields null.

Template

{{ x | uniq }}

Context

{
    "x": "aabb"
}

Output

null

Source fixture: transforms/transform-uniq.json