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

    Function forEach

    • Creates a sink handing every item to a consumer.

      The feed is drained without retaining any item, making this the sink of choice for pipes run for their side effects rather than for a collected result.

      Type Parameters

      • V

        The type of items in the feed

      Parameters

      • consumer: (item: 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))
      (forEach(n => console.log(n)))
      ); // logs 1, 2, 3; 3