yta
    Preparing search index...

    Function find

    • Consume the iterator and return the first item where the predicate function returns true.

      import { pipe } from "yta";
      import { find, of } from "yta/async";

      await pipe(
      of(
      { name: "foo", value: 42 },
      { name: "bar", value: 5 },
      { name: "baz", value: 101 },
      ),
      find(({ name }) => name === "bar"),
      );
      // => { name: bar, value: 101 }

      Type Parameters

      • A

      Parameters

      • p: (item: A) => boolean

        The predicate function

      Returns (items: AsyncIterable<A>) => Promise<A | undefined>