@metreeca/pipe - v0.9.20
    Preparing search index...

    Function find

    • Creates a sink retrieving the first item that satisfies the predicate.

      Type Parameters

      • V

        The type of items in the stream

      Parameters

      • predicate: (item: V) => boolean | Promise<boolean>

        The function to test each item

      Returns Sink<V, V | undefined>

      A sink that retrieves the first matching item or undefined

      await items([1, 2, 3, 4, 5])(find(x => x > 3));  // 4
      await items([1, 2, 3])(find(x => x > 5)); // undefined