Skip to main content

$$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​

ArgumentTypeValuesRequired / Default ValueDescription
PrimaryarrayYesArray of elements
byTransformer(##current,##index)YesA predicate transformer for an element
  • ##current - Current element
  • ##index - Current index

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
]
]