$$find
Find the first element in a specified array that satisfy the predicate transformer
Usage​
{
"$$find": /* Array of elements */,
"by": "##current" /* Transformer(##current,##index) */
}
"$$find([by]):{input}"
note
Concrete values in the usage example are default values.
info
predicate by
should resolve to a boolean
value, it uses the truthy logic
Returns​
Same as found element
Arguments​
Argument | Type | Values | Required / Default Value | Description |
---|---|---|---|---|
Primary | array | Yes | Array of elements | |
by | Transformer(##current ,##index ) | ##current | A predicate transformer for an element
|
Examples​
Input
Definition
Output
[
0,
[],
"a"
]
{
"$$find": "$",
"by": "##current"
}
"a"
[
"a",
"1",
"true"
]
{
"$$find": "$",
"by": "$$boolean:##current"
}
"true"
[
{
"name": "alice"
},
{
"name": "ann"
},
{
"name": "Bob"
}
]
{
"$$find": "$",
"by": "$$test('(?i)^b'):##current.name"
}
{
"name": "Bob"
}
[
0,
[],
"a"
]
"$$find(##current):$"
"a"