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

    Function each

    • Creates a sink handing every item to a consumer.

      Items are handed over in source order. This is the sink of choice for pipes run for their side effects rather than for a collected result.

      Warning

      • Exhaustive: every item is handed over before the sink resolves, so an infinite feed never completes.
      • Streaming: items are handed over one at a time, none retained.
      • Stateful: the resolved count covers the items drawn, so a sink closing a nested or truncated feed counts those alone.

      Type Parameters

      • V

        The type of items in the feed

      Parameters

      • consumer: (item: NoInfer<V>) => unknown

        The function processing each item; a returned promise is awaited before the next item is pulled, so items are processed one at a time

      Returns Sink<V, number>

      A sink resolving to the number of items handed to consumer

      await pipe(
      (items([1, 2, 3]))
      (each(n => console.log(n)))
      ); // logs 1, 2, 3; 3