A simple example with numbers
--1--1--2--2--2--1--2--3--4--3--2--1--
distinct()
--1-----2--------------3--4-----------
An example using the selector function
--{a:4,n:'f'}--{a:7,n:'b'}--{a:5,n:'f'}--
distinct({ selector: ({ n }) => n })
--{a:4,n:'f'}--{a:7,n:'b'}---------------
An example using the flushes parameter.
--1--1--2--2--2--1--2--3--4--3--2--1--
distinct({
flushes:
-------------F------------------------
})
--1-----2-----2--1-----3--4-----------
Generated using TypeDoc
A TransformStream that queues all items from a ReadableStream that are distinct by comparison from previous items.
If a
selectorfunction is provided, then it will project each value from the source observable into a new value that it will check for equality with previously projected values. If theselectorfunction is not provided, it will use each value from the source observable directly with an equality check against previous values.A long-running
distinctuse might result in memory leaks. To help alleviate this in some scenarios, an optionalflushesparameter is also provided so that the internalSetcan be "flushed", basically clearing it of values.