Find All Items
Finds all items matching specified criteria using optimized search strategies.
findAll()
Finds all items matching specified criteria using optimized search strategies.
Signature
findAll(
matcher: string | number,
keySelector: KeySelector<T>,
options?: FindOptions<T>
): T[]Parameters
| Parameter | Type | Description |
|---|---|---|
matcher | string | number | Value to match against. |
keySelector | KeySelector<T> | Property name or value extractor function. |
options | FindOptions<T> | Search configuration options. |
Returns
T[] — Array of all matching items (empty array if none found).
Example Usage
playground.ts
Behavior Details
-
Search Flow:
- Checks cache first if
cacheKeyis provided. - Uses linear search for small datasets (less than 100 items).
- Uses binary search for larger sorted datasets.
- Falls back to fuzzy search when enabled.
- Checks cache first if
-
Result Handling:
- Returns all matches (not just the first one).
- Maintains the original item order in results.
- Returns an empty array if no matches are found.
-
Performance:
- Cached results: $O(1)$
- Linear search: $O(n)$
- Binary search: $O(\log n) + O(m)$ where $m$ is the number of matches.
- Fuzzy search: $O(n)$
Notes
- Cache Behavior: Results are cached for 5 minutes by default. The cache is automatically cleared when the dataset changes.
- String Matching: Case-insensitive by default. Exact matching unless
fuzzyis enabled. - Sorting: Auto-sorts when
needSortingis true. Skips sorting for pre-sorted data. Natural key order is used. - Edge Cases: Empty input returns an empty array. Handles null/undefined in data. Works with both numeric and string keys.
Last updated: Mon, Jun 15, 2026 06:09:51AM (UTC)
