$$filter
Filter input array to all the elements that satisfy the predicate transformer
Usage​
{
"$$filter": /* Array of elements */,
"by": /* Transformer(##current,##index) */
}
"$$filter(<by>):{input}"
info
predicate by
should resolve to a boolean
value, it uses the truthy logic
Returns​
array
- Same items type as input
Arguments​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | array | Yes | Array of elements | |
by | Transformer(##current ,##index ) | Yes | A predicate transformer for an element
|
Examples​
Input
Definition
Output
[
"a",
true,
"false",
0,
1,
[],
[
0
]
]
{
"$$filter": "$",
"by": "##current"
}
[
"a",
true,
"false",
1,
[
0
]
]
[
"a",
true,
"false",
0,
1,
[],
[
0
]
]
{
"$$filter": "$",
"by": "$$boolean:##current"
}
[
true,
1,
[
0
]
]
[
{
"name": "alice"
},
{
"name": "ann"
},
{
"name": "bob"
}
]
{
"$$filter": "$",
"by": "$$test(^a):##current.name"
}
[
{
"name": "alice"
},
{
"name": "ann"
}
]
[
"a",
true,
"false",
0,
1,
[],
[
0
]
]
"$$filter(##current):$"
[
"a",
true,
"false",
1,
[
0
]
]