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

    Function count

    • Creates a sink counting the items of the feed.

      Warning

      • Exhaustive: every item is drawn before the sink resolves, so an infinite feed never completes.
      • Streaming: no more than the running count is held in memory, whatever the size of the feed.
      • Stateful: the count covers the items drawn, so a sink closing a nested or truncated feed sees those alone.

      Type Parameters

      • V

        The type of items in the feed

      Returns Sink<V, number>

      A sink resolving to the number of items the feed carried

      await pipe(
      (items([1, 2, 3, 4, 5]))
      (count())
      ); // 5

      await pipe(
      (items<number>([]))
      (count())
      ); // 0