filterItems

Commons
stable

Filters a list of items against a query string using a configurable filter function. Supports per-key custom filters, key allowlists, and three filter modes: any-key (default), union, every, and intersection.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

items
required
readonly (readonly [item: IInternalItem, transformed: Record<string, unknown>])[] | readonly IInternalItem[]
The items to filter. Each element is either a plain item or a tuple of [original-item, transformed-item]. The transformed form is used for key lookups.
query
required
string
The search string to match against. When empty and noFilter is not set, all items are returned.
options
{ customKeyFilter?: TFilterKeyFunctions default?: TFilterFunction filterKeys?: TFilterKeys filterMode?: TFilterMode noFilter?: boolean }
Optional configuration: customKeyFilter (per-key filter functions), default (fallback filter, defaults to defaultFilter), filterKeys (allowlist of keys to search), filterMode (union | every | intersection), noFilter (bypass filtering).

API

Return value

The value returned by this util.

An array of match objects, each carrying the item's original index and a map of which keys matched (and at what position/value).

Usage

Examples

Ready-to-paste usage snippets.

Filter a list by query

typescript