Skip to main content

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

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

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"