@vgerbot/async
    Preparing search index...

    Function some

    • Checks whether at least one item satisfies an async predicate. Short-circuits scheduling when the first true is found.

      Type Parameters

      • I

      Parameters

      • data: I[] | Promise<I[]>

        Input array, or a promise that resolves to one.

      • predicate: (item: I, token: CancellableToken) => Promise<boolean>

        Async predicate to evaluate.

      • Optionaloptions: SomeOptions

        Configuration options including cancellation and concurrency.

      Returns CancellableHandle<boolean>

      A cancellable handle resolving to true if any item matches.

      const handle = some(
      [2, 4, 6, 7],
      async (item, token) => {
      await token.sleep(5);
      return item % 2 === 1;
      },
      { concurrency: 2 },
      );

      const hasOdd = await handle; // true
      const handle = some(
      { a: 2, b: 4, c: 5 },
      async (value, key) => key !== "a" && value % 2 === 1,
      );

      const hasMatch = await handle; // true
    • Checks whether at least one item satisfies an async predicate. Short-circuits scheduling when the first true is found.

      Type Parameters

      • I

      Parameters

      • data: CollectionInput<I> | Promise<CollectionInput<I>>

        Input array, or a promise that resolves to one.

      • predicate: (item: I, key: string | number, token: CancellableToken) => Promise<boolean>

        Async predicate to evaluate.

      • Optionaloptions: SomeOptions

        Configuration options including cancellation and concurrency.

      Returns CancellableHandle<boolean>

      A cancellable handle resolving to true if any item matches.

      const handle = some(
      [2, 4, 6, 7],
      async (item, token) => {
      await token.sleep(5);
      return item % 2 === 1;
      },
      { concurrency: 2 },
      );

      const hasOdd = await handle; // true
      const handle = some(
      { a: 2, b: 4, c: 5 },
      async (value, key) => key !== "a" && value % 2 === 1,
      );

      const hasMatch = await handle; // true