Unique In List With Predicate
Creates a duplicate-free version of a list, in which only the first occurrence of each element is kept, compared by predicate
Description
Creates a duplicate-free version of a list, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the list.
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 }
]- comparator =
(objectA, objectB) => objectA.age === objectB.age
- source = [
-
outputs
- result = [
{ "user": "barney", "age": 36, "active": true },
{ "user": "fred", "age": 40, "active": false },
{ "user": "pebbles", "age": 24, "active": true }
] - result = [
Inputs
- Source (Object): The collection to inspect. Could be in the form of List, Array and QueryResult
- Comparator (Boolean Comparator): The predicate function that compares the two objects from the list.
Inputs:
-Object A
: The left item of the list.
-Object B
: The right item of the list .
Outputs:
-result (Boolean)
: Set it totrue
ifobjects
are equal. The left object will be included in the result.
Outputs
- Error Flow (Error Flow): Triggered by providing unexpected type of the source.
- Result (Object): The new duplicate free list