API · Select

uniq()

Keep the first occurrence of every distinct value.

Signature

uniq(): Exstream<T, C>

Example

exstream(['eu', 'us', 'eu', 'apac', 'us']).uniq().valuesSync()
// ['eu', 'us', 'apac']

Equality

Seen values are stored in a JavaScript Set, so equality follows SameValueZero: NaN equals NaN, 0 equals -0, primitives compare by value, and objects compare by identity. Structurally equal object literals are distinct unless they are the same object reference. Use uniqBy() for a derived key.

Memory and pressure

uniq() is synchronous, stable, context-preserving, and adds no output queue. Its internal Set grows with the number of distinct values and is released when the branch ends; it is therefore unsuitable for an unbounded stream with unbounded key cardinality. Existing record errors pass through and are not stored.

Forms

stream.uniq()
exstream.pipeline().uniq()
exstream.uniq(stream)

uniqBy(), compact(), groupBy()