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

    Function find

    • Creates a sink retrieving the first item of the feed.

      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 resolves to undefined; callers wanting a default supply it with ??, and those requiring a value reach for seek instead.

      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, Optional<V>>

      A sink resolving to the first item of the feed, or to undefined if the feed carries none

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

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