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

    Function find

    • Creates a sink retrieving the first item matching a predicate.

      Items are tested in source order and consumption stops at the first match, leaving the rest of the feed unconsumed.

      Type Parameters

      • V

        The type of items in the feed

      Parameters

      • predicate: (item: V) => Awaitable<boolean>

        The function testing each item

      Returns Sink<V, V | undefined>

      A sink resolving to the first item matching predicate, or to undefined if no item does

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