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

    Function seek

    • Creates a sink retrieving the first item of the feed, failing if it carries none.

      Consumption stops at the first item, leaving the rest of the feed unconsumed; the first item meeting a condition is retrieved by drawing from a filter() upstream.

      An empty feed fails the sink instead of resolving to undefined as find does, so the item handed back is usable as is, with no check to tell a missing item from an undefined item the feed legitimately carries.

      Note

      • Incremental: a single item is drawn, so an infinite feed completes.
      • Streaming: the item is handed back as it is drawn, none retained.
      • Stateless: the outcome rests on the first item alone.

      Type Parameters

      • V

        The type of items in the feed

      Returns Sink<V, V>

      A sink resolving to the first item of the feed

      Error If the feed carries no item

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

      await pipe(
      (items([1, 2, 3, 4, 5]))
      (filter(n => n > 3))
      (seek())
      ); // 4