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

    Function peek

    • Creates a task observing the feed without altering it.

      Every item is handed to the consumer before being emitted unchanged, making the feed observable at any point of a pipe for tracing, logging or metering purposes.

      Type Parameters

      • V

        The type of items in the feed

      Parameters

      • consumer: (item: V) => unknown

        The function observing each item; a returned promise is awaited before the item moves on, so asynchronous side effects hold the feed back until they complete

      Returns Task<V>

      A task yielding the items of the feed unchanged

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