You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+82-8
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,10 @@ Fast fuzzy-search - the native replacement for `fuzzaldrin-plus`
6
6
* Fuzzaldrin plus is an awesome library that provides fuzzy-search that is more targeted towards filenames.
7
7
* Fuzzaldrin-plus-fast is a rewrite of the library in native C++ to make it fast. The goal is to make it a few hundred millisecond filter times for a dataset with 1M entries. This performance is helpful in Atom's fuzzy finder to open files from large projects such as Chrome/Mozilla.
8
8
9
-
Fuzzaldrin-plus-fast also provides an additional `filterTree` function which allows to fuzzy filter text in nested tree-like objects.
9
+
### Extra featuers
10
+
Fuzzaldrin-plus-fast:
11
+
- provides `filterTree` function which allows to fuzzy filter text in nested tree-like objects.
12
+
- allows setting the candidates only once using `ArrayFilterer` and `TreeFilterer` classes, and then, perform `filter` multiple times. This is much more efficient than calling the `filter` or `filterTree` functions directly every time.
10
13
11
14
# How performance is improved?
12
15
Fuzzaldrin-plus-fast achieves 10x-20x performance improvement over Fuzzaldrin plus for chromium project with 300K files. This high performance is achieved using the following techniques.
**Performance Note**: use `ArrayFilterer` class if you call the `filter` function multiple times on a certain set of candidates. `filter` internally uses this class, however, in each call it sets the candidates from scratch which can slow down the process.
70
+
71
+
### ArrayFilterer class
72
+
73
+
ArrayFilterer is a class that allows to set the `candidates` only once and perform filtering on them multiple times. This is much more efficient than calling the `filter` function directly.
74
+
```typescript
75
+
exportclassArrayFilterer<T> {
76
+
constructor()
77
+
78
+
/** The method to set the candidates that are going to be filtered
79
+
* @paramcandidates An array of tree objects.
80
+
* @paramdataKey (optional) if `candidates` is an array of objects, pass the key in the object which holds the data. dataKey can be the options object passed to `filter` method (but this is deprecated).
**Performance Note**: use `TreeFilterer` class if you call the `filterTree` function multiple times on a certain set of candidates. `filterTree` internally uses this class, however, in each call it sets the candidates from scratch which can slow down the process.
138
+
139
+
### TreeFilterer class
140
+
`TreeFilterer` is a class that allows to set the `candidates` only once and perform filtering on them multiple times. This is much more efficient than calling the `filterTree` function directly.
141
+
142
+
```typescript
143
+
exportclassTreeFilterer<T> {
144
+
constructor()
145
+
146
+
/** The method to set the candidates that are going to be filtered
147
+
* @paramcandidates An array of tree objects.
148
+
* @paramdataKey the key of the object (and its children) which holds the data (defaults to `"data"`)
149
+
* @paramchildrenKey the key of the object (and its children) which hold the children (defaults to `"children"`)
/** The method to perform the filtering on the already set candidates
154
+
* @paramquery A string query to match each candidate against.
155
+
* @paramoptions options
156
+
* @return An array of candidate objects in form of `{data, index, level}` sorted by best match against the query. Each objects has the address of the object in the tree using `index` and `level`.
0 commit comments