@metreeca/flow - v0.9.21
    Preparing search index...

    Function toSet

    • Creates a sink collecting the distinct items of the feed into a set.

      Items are made immutable as they are collected, in first-appearance order, and compared with SameValueZero semantics, so NaN matches itself and -0 matches 0.

      The returned set is frozen, with add, delete and clear shadowed by own properties that throw: entries cannot be altered through the set, although mutating methods invoked directly on Set.prototype still reach the internal slots backing them.

      Warning

      Accumulates the whole feed in memory. For large or infinite feeds, this may exhaust memory or never complete.

      Warning

      Freezing clones structured items, giving them a fresh identity: entries are not reachable through the original item reference, and the same mutable item collected twice yields two distinct entries rather than being deduplicated. Supply structured items as immutable values to keep their identity stable.

      Type Parameters

      • V

        The type of items in the feed

      Returns Sink<V, ReadonlySet<V>>

      A sink resolving to the deeply immutable read-only set of the distinct items of the feed

      await pipe(
      (items(1, 2, 2, 3, 3, 3))
      (toSet())
      ); // Set(3) { 1, 2, 3 }