@devisfuture/mega-collection 2.0.3 → 2.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.
- package/README.md +14 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,10 +100,11 @@ Each instance keeps its own data and its own indexes, so they work separately
|
|
|
100
100
|
and do not overwrite each other.
|
|
101
101
|
|
|
102
102
|
Each engine accepts an optional `fields` array (set via the `search`,
|
|
103
|
-
`filter` or `sort` option) which tells it which properties should
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
to scan the full
|
|
103
|
+
`filter` or `sort` option) which tells it which properties should use indexed
|
|
104
|
+
execution. Those indexes are built lazily on the first matching operation, so
|
|
105
|
+
initial engine creation stays fast even for very large collections. If you skip
|
|
106
|
+
`fields`, everything still works, but the engine may need to scan the full
|
|
107
|
+
array.
|
|
107
108
|
|
|
108
109
|
```ts
|
|
109
110
|
import { MergeEngines } from "@devisfuture/mega-collection";
|
|
@@ -175,8 +176,9 @@ The examples below show the difference between simple fields and nested fields.
|
|
|
175
176
|
```ts
|
|
176
177
|
import { TextSearchEngine } from "@devisfuture/mega-collection/search";
|
|
177
178
|
|
|
178
|
-
// `fields` tells the engine which fields
|
|
179
|
-
// If you skip `fields`, search still
|
|
179
|
+
// `fields` tells the engine which fields should use indexed search.
|
|
180
|
+
// The index is built lazily on first use. If you skip `fields`, search still
|
|
181
|
+
// works, but it will scan the full dataset.
|
|
180
182
|
const engine = new TextSearchEngine<User>({
|
|
181
183
|
data: users,
|
|
182
184
|
fields: ["name", "city"],
|
|
@@ -227,8 +229,9 @@ The examples below show the difference between simple fields and nested fields.
|
|
|
227
229
|
```ts
|
|
228
230
|
import { FilterEngine } from "@devisfuture/mega-collection/filter";
|
|
229
231
|
|
|
230
|
-
// `fields` tells the engine which fields should
|
|
231
|
-
//
|
|
232
|
+
// `fields` tells the engine which fields should use indexed filter lookups.
|
|
233
|
+
// The index is built lazily on first use. Without `fields`, filtering still
|
|
234
|
+
// works, but it will scan the data.
|
|
232
235
|
const engine = new FilterEngine<User>({
|
|
233
236
|
data: users,
|
|
234
237
|
fields: ["city", "age"],
|
|
@@ -287,8 +290,9 @@ Use `SortEngine` when you only need sorting.
|
|
|
287
290
|
```ts
|
|
288
291
|
import { SortEngine } from "@devisfuture/mega-collection/sort";
|
|
289
292
|
|
|
290
|
-
// `fields` tells the engine which fields should
|
|
291
|
-
//
|
|
293
|
+
// `fields` tells the engine which fields should use cached single-field
|
|
294
|
+
// sorting. The cache is built lazily on first use. If you skip `fields`,
|
|
295
|
+
// sorting still works.
|
|
292
296
|
const engine = new SortEngine<User>({
|
|
293
297
|
data: users,
|
|
294
298
|
fields: ["age", "name", "city"],
|