@devisfuture/mega-collection 1.1.1 → 1.1.4

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.
Files changed (2) hide show
  1. package/README.md +13 -5
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  What does this package solve?
12
12
 
13
- Sometimes in projects, you need to iterate through huge collections (20,000, 40,000, 80,000 elements in an array) that have come from the server. Usually, the most common features are searching, filtering, and sorting.
13
+ Sometimes in projects, you need to iterate through huge collections (100K+ elements in an array) that have come from the server. Usually, the most common features are searching, filtering, and sorting.
14
14
  So, this package helps to perform searching, filtering, and sorting of large collections faster than standard JavaScript methods. This operation is performed before rendering the UI content.
15
15
 
16
16
  Zero dependencies. Tree-shakeable. Import only what you need.
@@ -83,7 +83,7 @@ const engine = new MergeEngines<User>({
83
83
  // dataset is passed once at init — no need to repeat it in every call
84
84
  engine.search("john");
85
85
  engine.sort([{ field: "age", direction: "asc" }]);
86
- engine.filter([{ field: "city", values: ["Kyiv", "Lviv"] }]);
86
+ engine.filter([{ field: "city", values: ["Miami", "New York"] }]);
87
87
  ```
88
88
 
89
89
  ---
@@ -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
  ```
@@ -122,13 +130,13 @@ const engine = new FilterEngine<User>({
122
130
  });
123
131
 
124
132
  engine.filter([
125
- { field: "city", values: ["Kyiv", "Lviv"] },
133
+ { field: "city", values: ["Miami", "New York"] },
126
134
  { field: "age", values: [25, 30, 35] },
127
135
  ]);
128
136
 
129
137
  // Sequential mode example:
130
138
  // 1) First call filters by city
131
- const byCity = engine.filter([{ field: "city", values: ["Dnipro"] }]);
139
+ const byCity = engine.filter([{ field: "city", values: ["Miami"] }]);
132
140
  // 2) Second call filters only inside previous result
133
141
  const byCityAndAge = engine.filter([{ field: "age", values: [22] }]);
134
142
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devisfuture/mega-collection",
3
- "version": "1.1.1",
3
+ "version": "1.1.4",
4
4
  "description": "High-performance search, filter & sort engine for 100K+ item collections in JavaScript/TypeScript",
5
5
  "exports": {
6
6
  ".": {