Home > sculp-js > fuzzySearchTree
fuzzySearchTree() function
Fuzzy search function that returns nodes containing the search character and their ancestor nodes. Suitable for character filtering in tree components.
Two search conditions are available, processed in priority order: 1. Filter function filter, returning true/false. 2. Keyword matching, supporting case-insensitive check.
Features: 1. Configurable removeEmptyChild field to decide whether to remove empty children fields in search results. 2. If no filter condition is provided, or keyword mode is used with an empty keyword, the original object is returned; otherwise, a new array is returned.
Signature:
export declare function fuzzySearchTree<V>(nodes: V[], filterCondition: IFilterCondition<V>, options?: ISearchTreeOpts): V[];Parameters
Parameter | Type | Description |
|---|---|---|
nodes | V[] | Tree nodes |
filterCondition | Filter conditions | |
options | (Optional) Default configuration: { childField: 'children', nameField: 'name', removeEmptyChild: false, ignoreCase: true } |
Returns:
V[]
{V[]} Filtered tree nodes