Skip to content

Commit e59a3a3

Browse files
committed
improve pipeline and add docs
1 parent a55060a commit e59a3a3

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@ search("App");
3838

3939
Combined with libraries like [Moon](http://moonjs.ga), you can create a simple real-time search.
4040

41+
### Pipeline
42+
43+
Wade uses a pipeline to preprocess data and search queries. By default, this pipeline will:
44+
45+
* Make everything lowercase
46+
* Remove stop words
47+
48+
A pipeline consists of different functions that process a string and modify it in some way, and return the string.
49+
50+
You can easily modify the pipeline as it is available in `Wade.pipeline`, for example:
51+
52+
```js
53+
// Don't preprocess at all
54+
Wade.pipeline = [];
55+
56+
// Add custom processor to remove periods
57+
Wade.pipeline.push(function(str) {
58+
return str.replace(/\./g, "");
59+
});
60+
```
61+
62+
All functions will be executed in the order of the pipeline (0-n) and they will be used on each document in the data.
63+
4164
### License
4265

4366
Licensed under the [MIT License](https://kingpixil.github.io/license) by [Kabir Shah](https://kabir.ml)

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ var removeStopWords = function(str) {
6868
var Wade = function(data) {
6969
var search = function(item) {
7070
var data = search.data;
71-
var keywords = item.split(" ");
71+
var keywords = Wade.process(item).split(" ");
7272
var keywordsLength = keywords.length;
7373
var lengths = new Array(keywordsLength);
7474
var tables = new Array(keywordsLength);
7575
var results = [];
7676

7777
for(var i = 0; i < keywordsLength; i++) {
78-
var keyword = Wade.process(keywords[i]);
78+
var keyword = keywords[i];
7979
var length = keyword.length;
8080
lengths[i] = length;
8181
tables[i] = createTable(keyword, length);

0 commit comments

Comments
 (0)