Toolbox-XToolbox-X

Find All Items Async

Asynchronously retrieves all items matching the specified criteria, supporting the same search strategies as findAll.

findAllAsync()

Asynchronously retrieves all items matching the specified criteria, supporting the same search strategies as findAll.

Signature

async findAllAsync(
  supplier: () => Promise<T[]>,
  matcher: string | number,
  keySelector: KeySelector<T>,
  options?: Omit<FindOptions<T>, 'data'>
): Promise<T[]>

Parameters

ParameterTypeDescription
supplier() => Promise<T[]>Async function providing the dataset.
matcherstring | numberValue to match against.
keySelectorKeySelector<T>Property name or value extractor function.
optionsOmit<FindOptions<T>, 'data'>Search configuration options (excluding data).

Returns

Promise<T[]> — Array of all matching items (empty if none found).

Description

This method provides an asynchronous interface to findAll, with identical search behavior but with support for:

  • Promise-based data loading.
  • Dynamic dataset updates.
  • Asynchronous data sources.

Example Usage

import { Finder } from 'toolbox-x';

interface Product {
  id: number;
  name: string;
  category: string;
}

const productFinder = new Finder<Product>([]);

// Basic Usage
const products = await productFinder.findAllAsync(
  async () => [
    { id: 1, name: 'Laptop', category: 'electronics' },
    { id: 2, name: 'Shirt', category: 'apparel' }
  ],
  'electronics',
  'category'
);

console.log(products);

Behavior

  1. Data Loading: First awaits the supplier function.
  2. Search Execution: Delegates to findAll with the resolved data.
  3. Result Handling: Returns all matches (empty array if none).

Notes

  • Inherits all search behavior from findAll.
  • Supports the same caching and matching options.
  • Automatically handles promise resolution.
  • Rejects if supplier throws an error.

Last updated: Mon, Jun 15, 2026 06:09:51AM (UTC)

On this page