@devisfuture/mega-collection 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,9 +99,17 @@ import { TextSearchEngine } from "@devisfuture/mega-collection/search";
|
|
|
99
99
|
const engine = new TextSearchEngine<User>({
|
|
100
100
|
data: users,
|
|
101
101
|
fields: ["name", "city"],
|
|
102
|
-
minQueryLength: 2,
|
|
102
|
+
minQueryLength: 2, // begins searching when query length >= 2
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
+
// note: inputs shorter than `minQueryLength` intentionally clear the
|
|
106
|
+
// result set. A one‑character search usually matches most of the dataset,
|
|
107
|
+
// so bypassing that work makes typing feel snappier. When the query length
|
|
108
|
+
// hits the threshold or exceeds it, the indexed search runs and query
|
|
109
|
+
// performance improves dramatically. Empty/blank queries still return an
|
|
110
|
+
// empty array, whereas short nonblank queries return the previous valid
|
|
111
|
+
// result so the UI doesn’t flush on every keystroke.
|
|
112
|
+
|
|
105
113
|
engine.search("john"); // searches all indexed fields, deduplicated
|
|
106
114
|
engine.search("name", "john"); // searches a specific field
|
|
107
115
|
```
|