Creates a task filtering out duplicate items.
Items are processed sequentially and output order is preserved. Only the first occurrence of each unique item is yielded.
The type of items in the stream
The type of comparison key
Optional
Optional function to extract comparison key from items
A task that filters out duplicate items
Maintains a Set of all seen items in memory. For large or infinite streams with many unique items, this may cause memory issues.
Set
await items([1, 2, 2, 3, 1])(distinct())(toArray()); // [1, 2, 3]// With selectorawait items([{id: 1}, {id: 2}, {id: 1}])(distinct(x => x.id))(toArray());// [{id: 1}, {id: 2}] Copy
await items([1, 2, 2, 3, 1])(distinct())(toArray()); // [1, 2, 3]// With selectorawait items([{id: 1}, {id: 2}, {id: 1}])(distinct(x => x.id))(toArray());// [{id: 1}, {id: 2}]
Creates a task filtering out duplicate items.
Items are processed sequentially and output order is preserved. Only the first occurrence of each unique item is yielded.