Skip to main content
Version: 2.13

Find In List

Enables to get the first element from the list that pass the test of the predicate function

Description​

Iterates over elements of List, returning the first element for which the provided function (predicate) returns true.

Important: the predicate function is supposed to be synchronous.

Example:​

  • inputs

    • source = [{ "user": "barney", "age": 36, "active": true },

    { "user": "fred", "age": 40, "active": false },

    { "user": "pebbles", "age": 24, "active": true },

    { "user": "travis", "age": 24, "active": true }]

    • where = (object, index, list) => object.age < 25
    • from index = 0
  • outputs

    • result = { "user": "pebbles", "age": 24, "active": true }

Inputs​

  • Source (Object): The collection to inspect. Could be in the form of List, Array and QueryResult
  • Where (List Predicate): The predicate function that test whether an item is present in the source list.
    Inputs:
    - item (Object): The current item of the list.
    - rank (Number): The rank of the current item.
    - list (List): The full list being iterated.

    Outputs:
    - result (Boolean): Set it to true if item is to be selected by the predicate and should be returned as a result.
  • From Index (Number): The index to search from

Outputs​

  • Result (Object): The found object or null
  • Error Flow (Error Flow): Triggered by providing unexpected type of the source