@orchidjs/sifter 0.7.5 → 0.7.6
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 +25 -3
- package/dist/cjs/diacritics.js +114 -64
- package/dist/cjs/diacritics.js.map +1 -1
- package/dist/cjs/sifter.js +8 -4
- package/dist/cjs/sifter.js.map +1 -1
- package/dist/cjs/utils.js +7 -1
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/diacritics.js +112 -65
- package/dist/esm/diacritics.js.map +1 -1
- package/dist/esm/sifter.js +9 -5
- package/dist/esm/sifter.js.map +1 -1
- package/dist/esm/utils.js +7 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/diacritics.d.ts +21 -32
- package/dist/types/sifter.d.ts +3 -3
- package/dist/types/types.d.ts +10 -8
- package/dist/types/utils.d.ts +5 -1
- package/dist/umd/sifter.js +125 -68
- package/dist/umd/sifter.js.map +1 -1
- package/dist/umd/sifter.min.js +48 -30
- package/dist/umd/sifter.min.js.map +1 -1
- package/lib/diacritics.ts +142 -78
- package/lib/sifter.ts +9 -6
- package/lib/types.ts +12 -8
- package/lib/utils.ts +9 -2
- package/package.json +7 -3
- package/.config/babel.config.json +0 -17
- package/.config/rollup.config.js +0 -95
- package/.config/tsconfig.json +0 -16
- package/.travis.yml +0 -9
- package/Makefile +0 -27
- package/build/cjs/diacritics.js +0 -123
- package/build/cjs/diacritics.js.map +0 -1
- package/build/cjs/sifter.js +0 -373
- package/build/cjs/sifter.js.map +0 -1
- package/build/cjs/utils.js +0 -108
- package/build/cjs/utils.js.map +0 -1
- package/build/esm/diacritics.js +0 -117
- package/build/esm/diacritics.js.map +0 -1
- package/build/esm/sifter.js +0 -371
- package/build/esm/sifter.js.map +0 -1
- package/build/esm/utils.js +0 -98
- package/build/esm/utils.js.map +0 -1
- package/build/umd/sifter.js +0 -583
- package/build/umd/sifter.js.map +0 -1
- package/build/umd/sifter.min.js +0 -66
- package/build/umd/sifter.min.js.map +0 -1
- package/coverage/clover.xml +0 -217
- package/coverage/coverage-final.json +0 -4
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/diacritics.ts.html +0 -941
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -141
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sifter.ts.html +0 -1160
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov-report/utils.ts.html +0 -398
- package/coverage/lcov.info +0 -429
- package/release.sh +0 -119
- package/test/getScoreFunction.js +0 -55
- package/test/prepareSearch.js +0 -40
- package/test/search.js +0 -307
- package/test/sorting.js +0 -193
- package/test/tokenize.js +0 -63
- package/test/utils.js +0 -28
package/dist/types/utils.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ export declare const getAttrNesting: (obj: {
|
|
|
24
24
|
*
|
|
25
25
|
*/
|
|
26
26
|
export declare const scoreValue: (value: string, token: any, weight: number) => number;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
|
|
30
|
+
*/
|
|
27
31
|
export declare const escape_regex: (str: string) => string;
|
|
28
32
|
/**
|
|
29
33
|
* Cast object property to an array if it exists and has a value
|
|
@@ -31,7 +35,7 @@ export declare const escape_regex: (str: string) => string;
|
|
|
31
35
|
*/
|
|
32
36
|
export declare const propToArray: (obj: {
|
|
33
37
|
[key: string]: any;
|
|
34
|
-
}, key: string) =>
|
|
38
|
+
}, key: string) => any;
|
|
35
39
|
/**
|
|
36
40
|
* Iterates over arrays and hashes.
|
|
37
41
|
*
|
package/dist/umd/sifter.js
CHANGED
|
@@ -6,12 +6,23 @@
|
|
|
6
6
|
}(this, (function () { 'use strict';
|
|
7
7
|
|
|
8
8
|
// https://github.com/andrewrk/node-diacritics/blob/master/index.js
|
|
9
|
+
var latin_pat;
|
|
10
|
+
const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}]'; // \u{2bc}
|
|
11
|
+
|
|
12
|
+
const accent_reg = new RegExp(accent_pat, 'g');
|
|
13
|
+
var diacritic_patterns;
|
|
14
|
+
const latin_convert = {
|
|
15
|
+
'æ': 'ae',
|
|
16
|
+
'ⱥ': 'a',
|
|
17
|
+
'ø': 'o'
|
|
18
|
+
};
|
|
19
|
+
const convert_pat = new RegExp(Object.keys(latin_convert).join('|'), 'g');
|
|
9
20
|
/**
|
|
10
21
|
* code points generated from toCodePoints();
|
|
11
22
|
* removed 65339 to 65345
|
|
12
23
|
*/
|
|
13
24
|
|
|
14
|
-
|
|
25
|
+
const code_points = [[67, 67], [160, 160], [192, 438], [452, 652], [961, 961], [1019, 1019], [1083, 1083], [1281, 1289], [1984, 1984], [5095, 5095], [7429, 7441], [7545, 7549], [7680, 7935], [8580, 8580], [9398, 9449], [11360, 11391], [42792, 42793], [42802, 42851], [42873, 42897], [42912, 42922], [64256, 64260], [65313, 65338], [65345, 65370]];
|
|
15
26
|
/**
|
|
16
27
|
* Remove accents
|
|
17
28
|
* via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
|
|
@@ -19,50 +30,106 @@
|
|
|
19
30
|
*/
|
|
20
31
|
|
|
21
32
|
const asciifold = str => {
|
|
22
|
-
return str.normalize('
|
|
33
|
+
return str.normalize('NFKD').replace(accent_reg, '').toLowerCase().replace(convert_pat, function (foreignletter) {
|
|
34
|
+
return latin_convert[foreignletter];
|
|
35
|
+
});
|
|
23
36
|
};
|
|
24
37
|
/**
|
|
25
|
-
*
|
|
38
|
+
* Convert array of strings to a regular expression
|
|
39
|
+
* ex ['ab','a'] => (?:ab|a)
|
|
40
|
+
* ex ['a','b'] => [ab]
|
|
26
41
|
*
|
|
27
42
|
*/
|
|
28
43
|
|
|
29
44
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
|
|
45
|
+
const arrayToPattern = (chars, glue = '|') => {
|
|
46
|
+
if (chars.length == 1) {
|
|
47
|
+
return chars[0];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var longest = 1;
|
|
51
|
+
chars.forEach(a => {
|
|
52
|
+
longest = Math.max(longest, a.length);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (longest == 1) {
|
|
56
|
+
return '[' + chars.join('') + ']';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return '(?:' + chars.join(glue) + ')';
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Get all possible combinations of substrings that add up to the given string
|
|
63
|
+
* https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
40
66
|
|
|
67
|
+
const allSubstrings = input => {
|
|
68
|
+
if (input.length === 1) return [[input]];
|
|
69
|
+
var result = [];
|
|
70
|
+
allSubstrings(input.substring(1)).forEach(function (subresult) {
|
|
71
|
+
var tmp = subresult.slice(0);
|
|
72
|
+
tmp[0] = input.charAt(0) + tmp[0];
|
|
73
|
+
result.push(tmp);
|
|
74
|
+
tmp = subresult.slice(0);
|
|
75
|
+
tmp.unshift(input.charAt(0));
|
|
76
|
+
result.push(tmp);
|
|
77
|
+
});
|
|
78
|
+
return result;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Generate a list of diacritics from the list of code points
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
const generateDiacritics = () => {
|
|
86
|
+
var diacritics = {};
|
|
41
87
|
code_points.forEach(code_range => {
|
|
42
88
|
for (let i = code_range[0]; i <= code_range[1]; i++) {
|
|
43
89
|
let diacritic = String.fromCharCode(i);
|
|
44
|
-
let latin = diacritic
|
|
90
|
+
let latin = asciifold(diacritic);
|
|
45
91
|
|
|
46
|
-
if (latin == diacritic) {
|
|
47
|
-
//no_latin.push(diacritic);
|
|
92
|
+
if (latin == diacritic.toLowerCase()) {
|
|
48
93
|
continue;
|
|
49
94
|
}
|
|
50
95
|
|
|
51
|
-
latin
|
|
52
|
-
|
|
53
|
-
if (latin in latin_convert) {
|
|
54
|
-
latin = latin_convert[latin];
|
|
96
|
+
if (!(latin in diacritics)) {
|
|
97
|
+
diacritics[latin] = [latin];
|
|
55
98
|
}
|
|
56
99
|
|
|
57
|
-
|
|
58
|
-
|
|
100
|
+
var patt = new RegExp(arrayToPattern(diacritics[latin]), 'iu');
|
|
101
|
+
|
|
102
|
+
if (diacritic.match(patt)) {
|
|
103
|
+
continue;
|
|
59
104
|
}
|
|
60
105
|
|
|
61
|
-
diacritics[latin]
|
|
106
|
+
diacritics[latin].push(diacritic);
|
|
62
107
|
}
|
|
63
|
-
});
|
|
108
|
+
});
|
|
109
|
+
var latin_chars = Object.keys(diacritics); // latin character pattern
|
|
110
|
+
// match longer substrings first
|
|
111
|
+
|
|
112
|
+
latin_chars = latin_chars.sort((a, b) => b.length - a.length);
|
|
113
|
+
latin_pat = new RegExp('(' + arrayToPattern(latin_chars) + accent_pat + '*)', 'g'); // build diacritic patterns
|
|
114
|
+
// ae needs:
|
|
115
|
+
// (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
|
|
116
|
+
|
|
117
|
+
var diacritic_patterns = {};
|
|
118
|
+
latin_chars.sort((a, b) => a.length - b.length).forEach(latin => {
|
|
119
|
+
var substrings = allSubstrings(latin);
|
|
120
|
+
var pattern = substrings.map(sub_pat => {
|
|
121
|
+
sub_pat = sub_pat.map(l => {
|
|
122
|
+
if (diacritics.hasOwnProperty(l)) {
|
|
123
|
+
return arrayToPattern(diacritics[l]);
|
|
124
|
+
}
|
|
64
125
|
|
|
65
|
-
|
|
126
|
+
return l;
|
|
127
|
+
});
|
|
128
|
+
return arrayToPattern(sub_pat, '');
|
|
129
|
+
});
|
|
130
|
+
diacritic_patterns[latin] = arrayToPattern(pattern);
|
|
131
|
+
});
|
|
132
|
+
return diacritic_patterns;
|
|
66
133
|
};
|
|
67
134
|
/**
|
|
68
135
|
* Expand a regular expression pattern to include diacritics
|
|
@@ -70,54 +137,34 @@
|
|
|
70
137
|
*
|
|
71
138
|
*/
|
|
72
139
|
|
|
73
|
-
var diacritics = null;
|
|
74
140
|
const diacriticRegexPoints = regex => {
|
|
75
|
-
if (
|
|
76
|
-
|
|
141
|
+
if (diacritic_patterns === undefined) {
|
|
142
|
+
diacritic_patterns = generateDiacritics();
|
|
77
143
|
}
|
|
78
144
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
145
|
+
const decomposed = regex.normalize('NFKD').toLowerCase();
|
|
146
|
+
return decomposed.split(latin_pat).map(part => {
|
|
147
|
+
if (part == '') {
|
|
148
|
+
return '';
|
|
149
|
+
} // "ffl" or "ffl"
|
|
84
150
|
|
|
85
|
-
return regex;
|
|
86
|
-
};
|
|
87
|
-
/**
|
|
88
|
-
* Expand a regular expression pattern to include diacritics
|
|
89
|
-
* eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
|
|
90
|
-
*
|
|
91
|
-
* rollup will bundle this function (and the DIACRITICS constant) unless commented out
|
|
92
|
-
*
|
|
93
|
-
var diacriticRegex = (function() {
|
|
94
151
|
|
|
95
|
-
|
|
96
|
-
for( let letter in DIACRITICS ){
|
|
152
|
+
const no_accent = asciifold(part);
|
|
97
153
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
154
|
+
if (diacritic_patterns.hasOwnProperty(no_accent)) {
|
|
155
|
+
return diacritic_patterns[no_accent];
|
|
156
|
+
} // 'أهلا' (\u{623}\u{647}\u{644}\u{627}) or 'أهلا' (\u{627}\u{654}\u{647}\u{644}\u{627})
|
|
101
157
|
|
|
102
|
-
if( DIACRITICS.hasOwnProperty(letter) ){
|
|
103
158
|
|
|
104
|
-
|
|
105
|
-
if( letter.toUpperCase() in DIACRITICS ){
|
|
106
|
-
replace += letter.toUpperCase() + DIACRITICS[letter.toUpperCase()];
|
|
107
|
-
}
|
|
159
|
+
const composed_part = part.normalize('NFC');
|
|
108
160
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
161
|
+
if (composed_part != part) {
|
|
162
|
+
return arrayToPattern([part, composed_part]);
|
|
163
|
+
}
|
|
112
164
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
return regex;
|
|
118
|
-
}
|
|
119
|
-
})();
|
|
120
|
-
*/
|
|
165
|
+
return part;
|
|
166
|
+
}).join('');
|
|
167
|
+
};
|
|
121
168
|
|
|
122
169
|
// @ts-ignore TS2691 "An import path cannot end with a '.ts' extension"
|
|
123
170
|
|
|
@@ -163,8 +210,13 @@
|
|
|
163
210
|
if (pos === 0) score += 0.5;
|
|
164
211
|
return score * weight;
|
|
165
212
|
};
|
|
213
|
+
/**
|
|
214
|
+
*
|
|
215
|
+
* https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
|
|
216
|
+
*/
|
|
217
|
+
|
|
166
218
|
const escape_regex = str => {
|
|
167
|
-
return (str + '').replace(/([
|
|
219
|
+
return (str + '').replace(/([\$\(-\+\.\?\[-\^\{-\}])/g, '\\$1');
|
|
168
220
|
};
|
|
169
221
|
/**
|
|
170
222
|
* Cast object property to an array if it exists and has a value
|
|
@@ -173,6 +225,7 @@
|
|
|
173
225
|
|
|
174
226
|
const propToArray = (obj, key) => {
|
|
175
227
|
var value = obj[key];
|
|
228
|
+
if (typeof value == 'function') return value;
|
|
176
229
|
|
|
177
230
|
if (value && !Array.isArray(value)) {
|
|
178
231
|
obj[key] = [value];
|
|
@@ -283,7 +336,7 @@
|
|
|
283
336
|
|
|
284
337
|
tokens.push({
|
|
285
338
|
string: word,
|
|
286
|
-
regex: regex ? new RegExp(regex, '
|
|
339
|
+
regex: regex ? new RegExp(regex, 'iu') : null,
|
|
287
340
|
field: field
|
|
288
341
|
});
|
|
289
342
|
});
|
|
@@ -409,12 +462,17 @@
|
|
|
409
462
|
sort = !search.query && options.sort_empty ? options.sort_empty : options.sort,
|
|
410
463
|
sort_flds = [],
|
|
411
464
|
multipliers = [];
|
|
465
|
+
|
|
466
|
+
if (typeof sort == 'function') {
|
|
467
|
+
return sort.bind(this);
|
|
468
|
+
}
|
|
412
469
|
/**
|
|
413
470
|
* Fetches the specified sort field value
|
|
414
471
|
* from a search result item.
|
|
415
472
|
*
|
|
416
473
|
*/
|
|
417
474
|
|
|
475
|
+
|
|
418
476
|
const get_field = function get_field(name, result) {
|
|
419
477
|
if (name === '$score') return result.score;
|
|
420
478
|
return search.getAttrFn(self.items[result.id], name);
|
|
@@ -515,10 +573,9 @@
|
|
|
515
573
|
options.fields = fields;
|
|
516
574
|
}
|
|
517
575
|
|
|
518
|
-
query = asciifold(query + '').toLowerCase().trim();
|
|
519
576
|
return {
|
|
520
577
|
options: options,
|
|
521
|
-
query: query,
|
|
578
|
+
query: query.toLowerCase().trim(),
|
|
522
579
|
tokens: this.tokenize(query, options.respect_word_boundaries, weights),
|
|
523
580
|
total: 0,
|
|
524
581
|
items: [],
|
|
@@ -554,7 +611,7 @@
|
|
|
554
611
|
}
|
|
555
612
|
});
|
|
556
613
|
} else {
|
|
557
|
-
iterate(self.items, (
|
|
614
|
+
iterate(self.items, (_, id) => {
|
|
558
615
|
search.items.push({
|
|
559
616
|
'score': 1,
|
|
560
617
|
'id': id
|
package/dist/umd/sifter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sifter.js","sources":["../../lib/diacritics.ts","../../lib/utils.ts","../../lib/sifter.ts"],"sourcesContent":["\ntype TDiacraticList = {[key:string]:string};\n\n// https://github.com/andrewrk/node-diacritics/blob/master/index.js\nexport const DIACRITICS:TDiacraticList = {\n\t\" \":\" \",\n\t0:\"߀\",\n\tA:\"ⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ\",\n\tAA:\"Ꜳ\",\n\tAE:\"ÆǼǢ\",\n\tAO:\"Ꜵ\",\n\tAU:\"Ꜷ\",\n\tAV:\"ꜸꜺ\",\n\tAY:\"Ꜽ\",\n\tB:\"ⒷBḂḄḆɃƁ\",\n\tC:\"ⒸCꜾḈĆCĈĊČÇƇȻ\",\n\tD:\"ⒹDḊĎḌḐḒḎĐƊƉᴅꝹ\",\n\tDh:\"Ð\",\n\tDZ:\"DZDŽ\",\n\tDz:\"DzDž\",\n\tE:\"ɛⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎᴇ\",\n\tF:\"ꝼⒻFḞƑꝻ\",\n\tG:\"ⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾɢ\",\n\tH:\"ⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ\",\n\tI:\"ⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ\",\n\tJ:\"ⒿJĴɈȷ\",\n\tK:\"ⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ\",\n\tL:\"ⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ\",\n\tLJ:\"LJ\",\n\tLj:\"Lj\",\n\tM:\"ⓂMḾṀṂⱮƜϻ\",\n\tN:\"ꞤȠⓃNǸŃÑṄŇṆŅṊṈƝꞐᴎ\",\n\tNJ:\"NJ\",\n\tNj:\"Nj\",\n\tO:\"ⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ\",\n\tOE:\"Œ\",\n\tOI:\"Ƣ\",\n\tOO:\"Ꝏ\",\n\tOU:\"Ȣ\",\n\tP:\"ⓅPṔṖƤⱣꝐꝒꝔ\",\n\tQ:\"ⓆQꝖꝘɊ\",\n\tR:\"ⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ\",\n\tS:\"ⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ\",\n\tT:\"ⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ\",\n\tTh:\"Þ\",\n\tTZ:\"Ꜩ\",\n\tU:\"ⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ\",\n\tV:\"ⓋVṼṾƲꝞɅ\",\n\tVY:\"Ꝡ\",\n\tW:\"ⓌWẀẂŴẆẄẈⱲ\",\n\tX:\"ⓍXẊẌ\",\n\tY:\"ⓎYỲÝŶỸȲẎŸỶỴƳɎỾ\",\n\tZ:\"ⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ\",\n\ta:\"ⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑ\",\n\taa:\"ꜳ\",\n\tae:\"æǽǣ\",\n\tao:\"ꜵ\",\n\tau:\"ꜷ\",\n\tav:\"ꜹꜻ\",\n\tay:\"ꜽ\",\n\tb:\"ⓑbḃḅḇƀƃɓƂ\",\n\tc:\"cⓒćĉċčçḉƈȼꜿↄ\",\n\td:\"ⓓdḋďḍḑḓḏđƌɖɗƋᏧԁꞪ\",\n\tdh:\"ð\",\n\tdz:\"dzdž\",\n\te:\"ⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇǝ\",\n\tf:\"ⓕfḟƒ\",\n\tff:\"ff\",\n\tfi:\"fi\",\n\tfl:\"fl\",\n\tffi:\"ffi\",\n\tffl:\"ffl\",\n\tg:\"ⓖgǵĝḡğġǧģǥɠꞡꝿᵹ\",\n\th:\"ⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ\",\n\thv:\"ƕ\",\n\ti:\"ⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı\",\n\tj:\"ⓙjĵǰɉ\",\n\tk:\"ⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ\",\n\tl:\"ⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇɭ\",\n\tlj:\"lj\",\n\tm:\"ⓜmḿṁṃɱɯ\",\n\tn:\"ⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥлԉ\",\n\tnj:\"nj\",\n\to:\"ⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿꝋꝍɵɔᴑ\",\n\toe:\"œ\",\n\toi:\"ƣ\",\n\too:\"ꝏ\",\n\tou:\"ȣ\",\n\tp:\"ⓟpṕṗƥᵽꝑꝓꝕρ\",\n\tq:\"ⓠqɋꝗꝙ\",\n\tr:\"ⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ\",\n\ts:\"ⓢsśṥŝṡšṧṣṩșşȿꞩꞅẛʂ\",\n\tss:\"ß\",\n\tt:\"ⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ\",\n\tth:\"þ\",\n\ttz:\"ꜩ\",\n\tu:\"ⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ\",\n\tv:\"ⓥvṽṿʋꝟʌ\",\n\tvy:\"ꝡ\",\n\tw:\"ⓦwẁẃŵẇẅẘẉⱳ\",\n\tx:\"ⓧxẋẍ\",\n\ty:\"ⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ\",\n\tz:\"ⓩzźẑżžẓẕƶȥɀⱬꝣ\"\n}\n\n/**\n * code points generated from toCodePoints();\n * removed 65339 to 65345\n */\nvar code_points = [\n\t[ 67, 67 ],\n\t[ 160, 160 ],\n\t[ 192, 438 ],\n\t[ 452, 652 ],\n\t[ 961, 961 ],\n\t[ 1019, 1019 ],\n\t[ 1083, 1083 ],\n\t[ 1281, 1289 ],\n\t[ 1984, 1984 ],\n\t[ 5095, 5095 ],\n\t[ 7429, 7441 ],\n\t[ 7545, 7549 ],\n\t[ 7680, 7935 ],\n\t[ 8580, 8580 ],\n\t[ 9398, 9449 ],\n\t[ 11360, 11391 ],\n\t[ 42792, 42793 ],\n\t[ 42802, 42851 ],\n\t[ 42873, 42897 ],\n\t[ 42912, 42922 ],\n\t[ 64256, 64260 ],\n\t[ 65313, 65338 ],\n\t[ 65345, 65370 ]\n];\n\n/**\n * Remove accents\n * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703\n *\n */\nexport const asciifold = (str:string):string => {\n\treturn str.normalize('NFD').replace(/[\\u0300-\\u036F]/g, '').normalize('NFKD').toLowerCase();\n};\n\n\n/**\n * Convert list of diacritics to array of code points\n *\n */\n// @ts-ignore\nfunction toCodePoints(tolerance=8){\n\tvar char_codes:number[] = [];\n\n\tfor( let letter in DIACRITICS ){\n\t\tlet _diacritics = DIACRITICS[letter];\n\t\tfor( let n = 0; n < _diacritics.length; n++ ){\n\t\t\tvar code_point = _diacritics.codePointAt(n);\n\t\t\tif( code_point ) char_codes.push( code_point );\n\t\t}\n\t}\n\n\t//https://stackoverflow.com/questions/40431572/is-there-a-simple-way-to-group-js-array-values-by-range\n\tchar_codes.sort((a, b) => a - b);\n\tvar accumulator: number[][] = [];\n var result = char_codes.reduce(function (accumulator, currentValue, index, source) {\n\n\t\tif( !index ){\n\t\t\taccumulator.push( [currentValue,currentValue] );\n\n\t\t}else if( currentValue - source[index - 1] > tolerance ){\n\t\t\taccumulator.push( [currentValue,currentValue] );\n\n\t\t}else{\n\n\t\t\tlet range = accumulator.pop();\n\t\t\tif( range ){\n\t\t\t\taccumulator.push( [range[0],currentValue]);\n\t\t\t}\n\t\t}\n\n return accumulator;\n }, accumulator);\n\n\tconsole.log(`char_codes (${result.length})`,result);\n}\n\n/**\n * Generate a list of diacritics from the list of code points\n *\n */\nexport const generateDiacritics = ():TDiacraticList => {\n\n\tvar latin_convert:{[key:string]:string} = {\n\t\t'l·': 'l',\n\t\t'ʼn': 'n',\n\t\t'æ': 'ae',\n\t\t'ø': 'o',\n\t\t'aʾ': 'a',\n\t\t'dž': 'dz',\n\t};\n\n\tvar diacritics:{[key:string]:string} = {};\n\t//var no_latin\t= [];\n\tcode_points.forEach((code_range)=>{\n\n\t\tfor(let i = code_range[0]; i <= code_range[1]; i++){\n\t\t\tlet diacritic\t= String.fromCharCode(i);\n\t\t\tlet latin\t\t= diacritic.normalize('NFD').replace(/[\\u0300-\\u036F]/g, '').normalize('NFKD');\n\n\t\t\tif( latin == diacritic ){\n\t\t\t\t//no_latin.push(diacritic);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlatin = latin.toLowerCase();\n\n\t\t\tif( latin in latin_convert ){\n\t\t\t\tlatin = latin_convert[latin];\n\t\t\t}\n\n\t\t\tif( !(latin in diacritics) ){\n\t\t\t\tdiacritics[latin] = latin + latin.toUpperCase();\n\t\t\t}\n\t\t\tdiacritics[latin] += diacritic;\n\t\t}\n\t});\n\n\t//console.log('no_latin',JSON.stringify(no_latin));\n\n\treturn diacritics;\n}\n\n/**\n * Expand a regular expression pattern to include diacritics\n * \teg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/\n *\n */\nvar diacritics:null|TDiacraticList = null\nexport const diacriticRegexPoints = (regex:string):string => {\n\n\tif( diacritics === null ){\n\t\tdiacritics = generateDiacritics();\n\t}\n\n\tfor( let latin in diacritics ){\n\t\tif( diacritics.hasOwnProperty(latin) ){\n\t\t\tregex = regex.replace( new RegExp(latin,'g'), '['+diacritics[latin]+']');\n\t\t}\n\t}\n\treturn regex;\n}\n\n\n/**\n * Expand a regular expression pattern to include diacritics\n * \teg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/\n *\n * rollup will bundle this function (and the DIACRITICS constant) unless commented out\n *\nvar diacriticRegex = (function() {\n\n\tvar list = [];\n\tfor( let letter in DIACRITICS ){\n\n\t\tif( letter.toLowerCase() != letter && letter.toLowerCase() in DIACRITICS ){\n\t\t\tcontinue;\n\t\t}\n\n\t\tif( DIACRITICS.hasOwnProperty(letter) ){\n\n\t\t\tvar replace = letter + DIACRITICS[letter];\n\t\t\tif( letter.toUpperCase() in DIACRITICS ){\n\t\t\t\treplace += letter.toUpperCase() + DIACRITICS[letter.toUpperCase()];\n\t\t\t}\n\n\t\t\tlist.push({let:letter,pat:'['+replace+']'});\n\t\t}\n\t}\n\n\treturn function(regex:string):string{\n\t\tlist.forEach((item)=>{\n\t\t\tregex = regex.replace( new RegExp(item.let,'g'),item.pat);\n\t\t});\n\t\treturn regex;\n\t}\n})();\n*/\n","\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport { asciifold } from './diacritics.ts';\n\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport * as T from './types.ts';\n\n\n/**\n * A property getter resolving dot-notation\n * @param {Object} obj The root object to fetch property on\n * @param {String} name The optionally dotted property name to fetch\n * @return {Object} The resolved property value\n */\nexport const getAttr = (obj:{[key:string]:any}, name:string ) => {\n if (!obj ) return;\n return obj[name];\n};\n\n/**\n * A property getter resolving dot-notation\n * @param {Object} obj The root object to fetch property on\n * @param {String} name The optionally dotted property name to fetch\n * @return {Object} The resolved property value\n */\nexport const getAttrNesting = (obj:{[key:string]:any}, name:string ) => {\n if (!obj ) return;\n var part, names = name.split(\".\");\n\twhile( (part = names.shift()) && (obj = obj[part]));\n return obj;\n};\n\n/**\n * Calculates how close of a match the\n * given value is against a search token.\n *\n */\nexport const scoreValue = (value:string, token:T.Token, weight:number ):number => {\n\tvar score, pos;\n\n\tif (!value) return 0;\n\n\tvalue = value + '';\n\tpos = value.search(token.regex);\n\tif (pos === -1) return 0;\n\n\tscore = token.string.length / value.length;\n\tif (pos === 0) score += 0.5;\n\n\treturn score * weight;\n};\n\nexport const escape_regex = (str:string):string => {\n\treturn (str + '').replace(/([.?*+^$[\\]\\\\(){}|-])/g, '\\\\$1');\n};\n\n\n/**\n * Cast object property to an array if it exists and has a value\n *\n */\nexport const propToArray = (obj:{[key:string]:any}, key:string) => {\n\tvar value = obj[key];\n\tif( value && !Array.isArray(value) ){\n\t\tobj[key] = [value];\n\t}\n}\n\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:number|string)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n\n\n\nexport const cmp = (a:number|string, b:number|string) => {\n\tif (typeof a === 'number' && typeof b === 'number') {\n\t\treturn a > b ? 1 : (a < b ? -1 : 0);\n\t}\n\ta = asciifold(a + '').toLowerCase();\n\tb = asciifold(b + '').toLowerCase();\n\tif (a > b) return 1;\n\tif (b > a) return -1;\n\treturn 0;\n};\n","/**\n * sifter.js\n * Copyright (c) 2013–2020 Brian Reavis & contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this\n * file except in compliance with the License. You may obtain a copy of the License at:\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n * ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n *\n * @author Brian Reavis <brian@thirdroute.com>\n */\n\n // @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport { scoreValue, getAttr, getAttrNesting, escape_regex, propToArray, iterate, cmp } from './utils.ts';\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport { diacriticRegexPoints, asciifold } from './diacritics.ts';\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport * as T from 'types.ts';\n\nexport default class Sifter{\n\n\tpublic items; // []|{};\n\tpublic settings: T.Settings;\n\n\t/**\n\t * Textually searches arrays and hashes of objects\n\t * by property (or multiple properties). Designed\n\t * specifically for autocomplete.\n\t *\n\t */\n\tconstructor(items:any, settings:T.Settings) {\n\t\tthis.items = items;\n\t\tthis.settings = settings || {diacritics: true};\n\t};\n\n\t/**\n\t * Splits a search string into an array of individual\n\t * regexps to be used to match results.\n\t *\n\t */\n\ttokenize(query:string, respect_word_boundaries?:boolean, weights?:T.Weights ):T.Token[] {\n\t\tif (!query || !query.length) return [];\n\n\t\tconst tokens:T.Token[]\t= [];\n\t\tconst words\t\t\t\t= query.split(/\\s+/);\n\t\tvar field_regex:RegExp;\n\n\t\tif( weights ){\n\t\t\tfield_regex = new RegExp( '^('+ Object.keys(weights).map(escape_regex).join('|')+')\\:(.*)$');\n\t\t}\n\n\t\twords.forEach((word:string) => {\n\t\t\tlet field_match;\n\t\t\tlet field:null|string\t= null;\n\t\t\tlet regex:null|string\t= null;\n\n\t\t\t// look for \"field:query\" tokens\n\t\t\tif( field_regex && (field_match = word.match(field_regex)) ){\n\t\t\t\tfield\t= field_match[1];\n\t\t\t\tword\t= field_match[2];\n\t\t\t}\n\n\t\t\tif( word.length > 0 ){\n\t\t\t\tregex = escape_regex(word);\n\t\t\t\tif( this.settings.diacritics ){\n\t\t\t\t\tregex = diacriticRegexPoints(regex);\n\t\t\t\t}\n\t\t\t\tif( respect_word_boundaries ) regex = \"\\\\b\"+regex;\n\t\t\t}\n\n\t\t\ttokens.push({\n\t\t\t\tstring : word,\n\t\t\t\tregex : regex ? new RegExp(regex,'i') : null,\n\t\t\t\tfield : field,\n\t\t\t});\n\t\t});\n\n\t\treturn tokens;\n\t};\n\n\n\t/**\n\t * Returns a function to be used to score individual results.\n\t *\n\t * Good matches will have a higher score than poor matches.\n\t * If an item is not a match, 0 will be returned by the function.\n\t *\n\t * @returns {function}\n\t */\n\tgetScoreFunction(query:string, options:T.Options ){\n\t\tvar search = this.prepareSearch(query, options);\n\t\treturn this._getScoreFunction(search);\n\t}\n\n\t_getScoreFunction(search:T.PrepareObj ){\n\t\tconst tokens\t\t= search.tokens,\n\t\ttoken_count\t\t\t= tokens.length;\n\n\t\tif (!token_count) {\n\t\t\treturn function() { return 0; };\n\t\t}\n\n\t\tconst fields\t= search.options.fields,\n\t\tweights\t\t\t= search.weights,\n\t\tfield_count\t\t= fields.length,\n\t\tgetAttrFn\t\t= search.getAttrFn;\n\n\t\tif (!field_count) {\n\t\t\treturn function() { return 1; };\n\t\t}\n\n\n\t\t/**\n\t\t * Calculates the score of an object\n\t\t * against the search query.\n\t\t *\n\t\t */\n\t\tconst scoreObject = (function() {\n\n\n\t\t\tif (field_count === 1) {\n\t\t\t\treturn function(token:T.Token, data:{}) {\n\t\t\t\t\tconst field = fields[0].field;\n\t\t\t\t\treturn scoreValue(getAttrFn(data, field), token, weights[field]);\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn function(token:T.Token, data:{}) {\n\t\t\t\tvar sum = 0;\n\n\t\t\t\t// is the token specific to a field?\n\t\t\t\tif( token.field ){\n\n\t\t\t\t\tconst value = getAttrFn(data, token.field);\n\n\t\t\t\t\tif( !token.regex && value ){\n\t\t\t\t\t\tsum += (1/field_count);\n\t\t\t\t\t}else{\n\t\t\t\t\t\tsum += scoreValue(value, token, 1);\n\t\t\t\t\t}\n\n\n\n\t\t\t\t}else{\n\t\t\t\t\titerate(weights, (weight:number, field:string) => {\n\t\t\t\t\t\tsum += scoreValue(getAttrFn(data, field), token, weight);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn sum / field_count;\n\t\t\t};\n\t\t})();\n\n\t\tif (token_count === 1) {\n\t\t\treturn function(data:{}) {\n\t\t\t\treturn scoreObject(tokens[0], data);\n\t\t\t};\n\t\t}\n\n\t\tif (search.options.conjunction === 'and') {\n\t\t\treturn function(data:{}) {\n\t\t\t\tvar i = 0, score, sum = 0;\n\t\t\t\tfor (; i < token_count; i++) {\n\t\t\t\t\tscore = scoreObject(tokens[i], data);\n\t\t\t\t\tif (score <= 0) return 0;\n\t\t\t\t\tsum += score;\n\t\t\t\t}\n\t\t\t\treturn sum / token_count;\n\t\t\t};\n\t\t} else {\n\t\t\treturn function(data:{}) {\n\t\t\t\tvar sum = 0;\n\t\t\t\titerate(tokens,(token:T.Token)=>{\n\t\t\t\t\tsum += scoreObject(token, data);\n\t\t\t\t});\n\t\t\t\treturn sum / token_count;\n\t\t\t};\n\t\t}\n\t};\n\n\t/**\n\t * Returns a function that can be used to compare two\n\t * results, for sorting purposes. If no sorting should\n\t * be performed, `null` will be returned.\n\t *\n\t * @return function(a,b)\n\t */\n\tgetSortFunction(query:string, options:T.Options) {\n\t\tvar search = this.prepareSearch(query, options);\n\t\treturn this._getSortFunction(search);\n\t}\n\n\t_getSortFunction(search:T.PrepareObj){\n\t\tvar i, n, implicit_score;\n\n\t\tconst self\t= this,\n\t\toptions\t\t= search.options,\n\t\tsort\t\t= (!search.query && options.sort_empty) ? options.sort_empty : options.sort,\n\t\tsort_flds:T.Sort[]\t\t= [],\n\t\tmultipliers:number[]\t= [];\n\n\n\t\t/**\n\t\t * Fetches the specified sort field value\n\t\t * from a search result item.\n\t\t *\n\t\t */\n\t\tconst get_field = function(name:string, result:T.ResultItem):string|number {\n\t\t\tif (name === '$score') return result.score;\n\t\t\treturn search.getAttrFn(self.items[result.id], name);\n\t\t};\n\n\t\t// parse options\n\t\tif (sort) {\n\t\t\tfor (i = 0, n = sort.length; i < n; i++) {\n\t\t\t\tif (search.query || sort[i].field !== '$score') {\n\t\t\t\t\tsort_flds.push(sort[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// the \"$score\" field is implied to be the primary\n\t\t// sort field, unless it's manually specified\n\t\tif (search.query) {\n\t\t\timplicit_score = true;\n\t\t\tfor (i = 0, n = sort_flds.length; i < n; i++) {\n\t\t\t\tif (sort_flds[i].field === '$score') {\n\t\t\t\t\timplicit_score = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (implicit_score) {\n\t\t\t\tsort_flds.unshift({field: '$score', direction: 'desc'});\n\t\t\t}\n\t\t} else {\n\t\t\tfor (i = 0, n = sort_flds.length; i < n; i++) {\n\t\t\t\tif (sort_flds[i].field === '$score') {\n\t\t\t\t\tsort_flds.splice(i, 1);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0, n = sort_flds.length; i < n; i++) {\n\t\t\tmultipliers.push(sort_flds[i].direction === 'desc' ? -1 : 1);\n\t\t}\n\n\t\t// build function\n\t\tconst sort_flds_count = sort_flds.length;\n\t\tif (!sort_flds_count) {\n\t\t\treturn null;\n\t\t} else if (sort_flds_count === 1) {\n\t\t\tconst sort_fld = sort_flds[0].field;\n\t\t\tconst multiplier = multipliers[0];\n\t\t\treturn function(a:T.ResultItem, b:T.ResultItem) {\n\t\t\t\treturn multiplier * cmp(\n\t\t\t\t\tget_field(sort_fld, a),\n\t\t\t\t\tget_field(sort_fld, b)\n\t\t\t\t);\n\t\t\t};\n\t\t} else {\n\t\t\treturn function(a:T.ResultItem, b:T.ResultItem) {\n\t\t\t\tvar i, result, field;\n\t\t\t\tfor (i = 0; i < sort_flds_count; i++) {\n\t\t\t\t\tfield = sort_flds[i].field;\n\t\t\t\t\tresult = multipliers[i] * cmp(\n\t\t\t\t\t\tget_field(field, a),\n\t\t\t\t\t\tget_field(field, b)\n\t\t\t\t\t);\n\t\t\t\t\tif (result) return result;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t};\n\t\t}\n\t};\n\n\t/**\n\t * Parses a search query and returns an object\n\t * with tokens and fields ready to be populated\n\t * with results.\n\t *\n\t */\n\tprepareSearch(query:string, optsUser:T.Options):T.PrepareObj {\n\t\tconst weights:T.Weights = {};\n\t\tvar options\t\t= Object.assign({},optsUser);\n\n\t\tpropToArray(options,'sort');\n\t\tpropToArray(options,'sort_empty');\n\n\t\t// convert fields to new format\n\t\tif( options.fields ){\n\t\t\tpropToArray(options,'fields');\n\t\t\tconst fields:T.Field[] = [];\n\t\t\toptions.fields.forEach((field:string|T.Field) => {\n\t\t\t\tif( typeof field == 'string' ){\n\t\t\t\t\tfield = {field:field,weight:1};\n\t\t\t\t}\n\t\t\t\tfields.push(field);\n\t\t\t\tweights[field.field] = ('weight' in field) ? field.weight : 1;\n\t\t\t});\n\t\t\toptions.fields = fields;\n\t\t}\n\n\t\tquery = asciifold( query + '' ).toLowerCase().trim();\n\n\t\treturn {\n\t\t\toptions\t\t: options,\n\t\t\tquery\t\t: query,\n\t\t\ttokens\t\t: this.tokenize(query, options.respect_word_boundaries, weights),\n\t\t\ttotal\t\t: 0,\n\t\t\titems\t\t: [],\n\t\t\tweights\t\t: weights,\n\t\t\tgetAttrFn\t: (options.nesting) ? getAttrNesting : getAttr,\n\t\t};\n\t};\n\n\t/**\n\t * Searches through all items and returns a sorted array of matches.\n\t *\n\t */\n\tsearch(query:string, options:T.Options) : T.PrepareObj {\n\t\tvar self = this, score, search:T.PrepareObj;\n\n\t\tsearch = this.prepareSearch(query, options);\n\t\toptions = search.options;\n\t\tquery = search.query;\n\n\t\t// generate result scoring function\n\t\tconst fn_score = options.score || self._getScoreFunction(search);\n\n\t\t// perform search and sort\n\t\tif (query.length) {\n\t\t\titerate(self.items, (item:T.ResultItem, id:string|number) => {\n\t\t\t\tscore = fn_score(item);\n\t\t\t\tif (options.filter === false || score > 0) {\n\t\t\t\t\tsearch.items.push({'score': score, 'id': id});\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\titerate(self.items, (item:T.ResultItem, id:string|number) => {\n\t\t\t\tsearch.items.push({'score': 1, 'id': id});\n\t\t\t});\n\t\t}\n\n\t\tconst fn_sort = self._getSortFunction(search);\n\t\tif (fn_sort) search.items.sort(fn_sort);\n\n\t\t// apply limits\n\t\tsearch.total = search.items.length;\n\t\tif (typeof options.limit === 'number') {\n\t\t\tsearch.items = search.items.slice(0, options.limit);\n\t\t}\n\n\t\treturn search;\n\t};\n}\n"],"names":["code_points","asciifold","str","normalize","replace","toLowerCase","generateDiacritics","latin_convert","diacritics","forEach","code_range","i","diacritic","String","fromCharCode","latin","toUpperCase","diacriticRegexPoints","regex","hasOwnProperty","RegExp","getAttr","obj","name","getAttrNesting","part","names","split","shift","scoreValue","value","token","weight","score","pos","search","string","length","escape_regex","propToArray","key","Array","isArray","iterate","object","callback","cmp","a","b","Sifter","constructor","items","settings","tokenize","query","respect_word_boundaries","weights","tokens","words","field_regex","Object","keys","map","join","word","field_match","field","match","push","getScoreFunction","options","prepareSearch","_getScoreFunction","token_count","fields","field_count","getAttrFn","scoreObject","data","sum","conjunction","getSortFunction","_getSortFunction","n","implicit_score","self","sort","sort_empty","sort_flds","multipliers","get_field","result","id","unshift","direction","splice","sort_flds_count","sort_fld","multiplier","optsUser","assign","trim","total","nesting","fn_score","item","filter","fn_sort","limit","slice"],"mappings":";;;;;;;CAGA;CAsGA;CACA;CACA;CACA;;CACA,IAAIA,WAAW,GAAG,CACjB,CAAE,EAAF,EAAM,EAAN,CADiB,EAEjB,CAAE,GAAF,EAAO,GAAP,CAFiB,EAGjB,CAAE,GAAF,EAAO,GAAP,CAHiB,EAIjB,CAAE,GAAF,EAAO,GAAP,CAJiB,EAKjB,CAAE,GAAF,EAAO,GAAP,CALiB,EAMjB,CAAE,IAAF,EAAQ,IAAR,CANiB,EAOjB,CAAE,IAAF,EAAQ,IAAR,CAPiB,EAQjB,CAAE,IAAF,EAAQ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,MAAvB,CAAlC,CARsD;;;CAWtD,QAAImB,KAAK,CAACjB,MAAV,EAAkB;CACjBM,MAAAA,OAAO,CAAC0C,IAAI,CAAClC,KAAN,EAAa,CAACsD,IAAD,EAAoBb,EAApB,KAAyC;CAC5D3D,QAAAA,KAAK,GAAGuE,QAAQ,CAACC,IAAD,CAAhB;;CACA,YAAInC,OAAO,CAACoC,MAAR,KAAmB,KAAnB,IAA4BzE,KAAK,GAAG,CAAxC,EAA2C;CAC1CE,UAAAA,MAAM,CAACgB,KAAP,CAAaiB,IAAb,CAAkB;CAAC,qBAASnC,KAAV;CAAiB,kBAAM2D;CAAvB,WAAlB;CACA;CACD,OALM,CAAP;CAMA,KAPD,MAOO;CACNjD,MAAAA,OAAO,CAAC0C,IAAI,CAAClC,KAAN,EAAa,CAACsD,IAAD,EAAoBb,EAApB,KAAyC;CAC5DzD,QAAAA,MAAM,CAACgB,KAAP,CAAaiB,IAAb,CAAkB;CAAC,mBAAS,CAAV;CAAa,gBAAMwB;CAAnB,SAAlB;CACA,OAFM,CAAP;CAGA;;CAED,UAAMe,OAAO,GAAGtB,IAAI,CAACH,gBAAL,CAAsB/C,MAAtB,CAAhB;;CACA,QAAIwE,OAAJ,EAAaxE,MAAM,CAACgB,KAAP,CAAamC,IAAb,CAAkBqB,OAAlB,EAzByC;;CA4BtDxE,IAAAA,MAAM,CAACmE,KAAP,GAAenE,MAAM,CAACgB,KAAP,CAAad,MAA5B;;CACA,QAAI,OAAOiC,OAAO,CAACsC,KAAf,KAAyB,QAA7B,EAAuC;CACtCzE,MAAAA,MAAM,CAACgB,KAAP,GAAehB,MAAM,CAACgB,KAAP,CAAa0D,KAAb,CAAmB,CAAnB,EAAsBvC,OAAO,CAACsC,KAA9B,CAAf;CACA;;CAED,WAAOzE,MAAP;CACA;;CA/UyB;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"sifter.js","sources":["../../lib/diacritics.ts","../../lib/utils.ts","../../lib/sifter.ts"],"sourcesContent":["\ntype TDiacraticList = {[key:string]:string};\n\n// https://github.com/andrewrk/node-diacritics/blob/master/index.js\n\nvar latin_pat:RegExp;\nconst accent_pat = '[\\u0300-\\u036F\\u{b7}\\u{2be}]'; // \\u{2bc}\nconst accent_reg = new RegExp(accent_pat,'g');\nvar diacritic_patterns:TDiacraticList;\n\nconst latin_convert:TDiacraticList = {\n\t'æ': 'ae',\n\t'ⱥ': 'a',\n\t'ø': 'o',\n};\n\nconst convert_pat = new RegExp(Object.keys(latin_convert).join('|'),'g');\n\n\nexport const DIACRITICS:TDiacraticList = {\n\t\" \":\" \",\n\t0:\"߀\",\n\tA:\"ⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ\",\n\tAA:\"Ꜳ\",\n\tAE:\"ÆǼǢ\",\n\tAO:\"Ꜵ\",\n\tAU:\"Ꜷ\",\n\tAV:\"ꜸꜺ\",\n\tAY:\"Ꜽ\",\n\tB:\"ⒷBḂḄḆɃƁ\",\n\tC:\"ⒸCꜾḈĆCĈĊČÇƇȻ\",\n\tD:\"ⒹDḊĎḌḐḒḎĐƊƉᴅꝹ\",\n\tDh:\"Ð\",\n\tDZ:\"DZDŽ\",\n\tDz:\"DzDž\",\n\tE:\"ɛⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎᴇ\",\n\tF:\"ꝼⒻFḞƑꝻ\",\n\tG:\"ⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾɢ\",\n\tH:\"ⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ\",\n\tI:\"ⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ\",\n\tJ:\"ⒿJĴɈȷ\",\n\tK:\"ⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ\",\n\tL:\"ⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ\",\n\tLJ:\"LJ\",\n\tLj:\"Lj\",\n\tM:\"ⓂMḾṀṂⱮƜϻ\",\n\tN:\"ꞤȠⓃNǸŃÑṄŇṆŅṊṈƝꞐᴎ\",\n\tNJ:\"NJ\",\n\tNj:\"Nj\",\n\tO:\"ⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ\",\n\tOE:\"Œ\",\n\tOI:\"Ƣ\",\n\tOO:\"Ꝏ\",\n\tOU:\"Ȣ\",\n\tP:\"ⓅPṔṖƤⱣꝐꝒꝔ\",\n\tQ:\"ⓆQꝖꝘɊ\",\n\tR:\"ⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ\",\n\tS:\"ⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ\",\n\tT:\"ⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ\",\n\tTh:\"Þ\",\n\tTZ:\"Ꜩ\",\n\tU:\"ⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ\",\n\tV:\"ⓋVṼṾƲꝞɅ\",\n\tVY:\"Ꝡ\",\n\tW:\"ⓌWẀẂŴẆẄẈⱲ\",\n\tX:\"ⓍXẊẌ\",\n\tY:\"ⓎYỲÝŶỸȲẎŸỶỴƳɎỾ\",\n\tZ:\"ⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ\",\n\ta:\"ⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑ\",\n\taa:\"ꜳ\",\n\tae:\"æǽǣ\",\n\tao:\"ꜵ\",\n\tau:\"ꜷ\",\n\tav:\"ꜹꜻ\",\n\tay:\"ꜽ\",\n\tb:\"ⓑbḃḅḇƀƃɓƂ\",\n\tc:\"cⓒćĉċčçḉƈȼꜿↄ\",\n\td:\"ⓓdḋďḍḑḓḏđƌɖɗƋᏧԁꞪ\",\n\tdh:\"ð\",\n\tdz:\"dzdž\",\n\te:\"ⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇǝ\",\n\tf:\"ⓕfḟƒ\",\n\tff:\"ff\",\n\tfi:\"fi\",\n\tfl:\"fl\",\n\tffi:\"ffi\",\n\tffl:\"ffl\",\n\tg:\"ⓖgǵĝḡğġǧģǥɠꞡꝿᵹ\",\n\th:\"ⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ\",\n\thv:\"ƕ\",\n\ti:\"ⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı\",\n\tj:\"ⓙjĵǰɉ\",\n\tk:\"ⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ\",\n\tl:\"ⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇɭ\",\n\tlj:\"lj\",\n\tm:\"ⓜmḿṁṃɱɯ\",\n\tn:\"ⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥлԉ\",\n\tnj:\"nj\",\n\to:\"ⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿꝋꝍɵɔᴑ\",\n\toe:\"œ\",\n\toi:\"ƣ\",\n\too:\"ꝏ\",\n\tou:\"ȣ\",\n\tp:\"ⓟpṕṗƥᵽꝑꝓꝕρ\",\n\tq:\"ⓠqɋꝗꝙ\",\n\tr:\"ⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ\",\n\ts:\"ⓢsśṥŝṡšṧṣṩșşȿꞩꞅẛʂ\",\n\tss:\"ß\",\n\tt:\"ⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ\",\n\tth:\"þ\",\n\ttz:\"ꜩ\",\n\tu:\"ⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ\",\n\tv:\"ⓥvṽṿʋꝟʌ\",\n\tvy:\"ꝡ\",\n\tw:\"ⓦwẁẃŵẇẅẘẉⱳ\",\n\tx:\"ⓧxẋẍ\",\n\ty:\"ⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ\",\n\tz:\"ⓩzźẑżžẓẕƶȥɀⱬꝣ\"\n}\n\n/**\n * code points generated from toCodePoints();\n * removed 65339 to 65345\n */\nexport const code_points = [\n\t[ 67, 67 ],\n\t[ 160, 160 ],\n\t[ 192, 438 ],\n\t[ 452, 652 ],\n\t[ 961, 961 ],\n\t[ 1019, 1019 ],\n\t[ 1083, 1083 ],\n\t[ 1281, 1289 ],\n\t[ 1984, 1984 ],\n\t[ 5095, 5095 ],\n\t[ 7429, 7441 ],\n\t[ 7545, 7549 ],\n\t[ 7680, 7935 ],\n\t[ 8580, 8580 ],\n\t[ 9398, 9449 ],\n\t[ 11360, 11391 ],\n\t[ 42792, 42793 ],\n\t[ 42802, 42851 ],\n\t[ 42873, 42897 ],\n\t[ 42912, 42922 ],\n\t[ 64256, 64260 ],\n\t[ 65313, 65338 ],\n\t[ 65345, 65370 ]\n];\n\n/**\n * Remove accents\n * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703\n *\n */\nexport const asciifold = (str:string):string => {\n\treturn str\n\t\t.normalize('NFKD')\n\t\t.replace(accent_reg, '')\n\t\t.toLowerCase()\n\t\t.replace(convert_pat,function(foreignletter) {\n\t\t\treturn latin_convert[foreignletter];\n\t\t});\n};\n\n\n/**\n * Convert list of diacritics to array of code points\n *\n */\n// @ts-ignore\nfunction toCodePoints(tolerance=8){\n\tvar char_codes:number[] = [];\n\n\tfor( let letter in DIACRITICS ){\n\t\tlet _diacritics = DIACRITICS[letter];\n\t\tfor( let n = 0; n < _diacritics.length; n++ ){\n\t\t\tvar code_point = _diacritics.codePointAt(n);\n\t\t\tif( code_point ) char_codes.push( code_point );\n\t\t}\n\t}\n\n\t//https://stackoverflow.com/questions/40431572/is-there-a-simple-way-to-group-js-array-values-by-range\n\tchar_codes.sort((a, b) => a - b);\n\tvar accumulator: number[][] = [];\n\tchar_codes.reduce(function (accumulator, currentValue, index, source) {\n\n\t\tif( !index ){\n\t\t\taccumulator.push( [currentValue,currentValue] );\n\n\t\t}else if( currentValue - source[index - 1] > tolerance ){\n\t\t\taccumulator.push( [currentValue,currentValue] );\n\n\t\t}else{\n\n\t\t\tlet range = accumulator.pop();\n\t\t\tif( range ){\n\t\t\t\taccumulator.push( [range[0],currentValue]);\n\t\t\t}\n\t\t}\n\n\t\treturn accumulator;\n\t}, accumulator);\n\n}\n\n/**\n * Convert array of strings to a regular expression\n *\tex ['ab','a'] => (?:ab|a)\n * \tex ['a','b'] => [ab]\n *\n */\nexport const arrayToPattern = (chars:string[],glue:string='|'):string =>{\n\t\n\tif( chars.length == 1 ){\n\t\treturn chars[0];\n\t}\n\t\n\tvar longest = 1;\n\tchars.forEach((a)=>{longest = Math.max(longest,a.length)});\n\n\tif( longest == 1 ){\n\t\treturn '['+chars.join('')+']';\n\t}\n\n\treturn '(?:'+chars.join(glue)+')';\t\n};\n\n/**\n * Get all possible combinations of substrings that add up to the given string\n * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string\n *\n */\nexport const allSubstrings = (input:string):string[][] => {\n\n if( input.length === 1) return [[input]];\n\n var result:string[][] = [];\n allSubstrings(input.substring(1)).forEach(function(subresult) {\n var tmp = subresult.slice(0);\n tmp[0] = input.charAt(0) + tmp[0];\n result.push(tmp);\n\n tmp = subresult.slice(0);\n tmp.unshift(input.charAt(0));\n result.push(tmp);\n });\n \n return result;\n}\n\n/**\n * Generate a list of diacritics from the list of code points\n *\n */\nexport const generateDiacritics = ():TDiacraticList => {\t\n\n\tvar diacritics:{[key:string]:string[]} = {};\n\tcode_points.forEach((code_range)=>{\n\n\t\tfor(let i = code_range[0]; i <= code_range[1]; i++){\n\t\t\t\n\t\t\tlet diacritic\t= String.fromCharCode(i);\n\t\t\tlet\tlatin\t\t= asciifold(diacritic);\n\n\t\t\tif( latin == diacritic.toLowerCase() ){\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif( !(latin in diacritics) ){\n\t\t\t\tdiacritics[latin] = [latin];\n\t\t\t}\n\t\t\t\n\t\t\tvar patt = new RegExp( arrayToPattern(diacritics[latin]),'iu');\n\t\t\tif( diacritic.match(patt) ){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tdiacritics[latin].push(diacritic);\n\t\t}\n\t});\n\t\t\n\tvar latin_chars = Object.keys(diacritics);\n\t\n\t\n\t// latin character pattern\n\t// match longer substrings first\n\tlatin_chars\t\t= latin_chars.sort((a, b) => b.length - a.length );\n\tlatin_pat\t\t= new RegExp('('+ arrayToPattern(latin_chars) + accent_pat + '*)','g');\n\t\n\t\n\t// build diacritic patterns\n\t// ae needs: \n\t//\t(?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))\n\tvar diacritic_patterns:TDiacraticList = {};\n\tlatin_chars.sort((a,b) => a.length -b.length).forEach((latin)=>{\n\t\t\n\t\tvar substrings\t= allSubstrings(latin);\n\t\tvar pattern = substrings.map((sub_pat)=>{\n\t\t\t\n\t\t\tsub_pat = sub_pat.map((l)=>{\n\t\t\t\tif( diacritics.hasOwnProperty(l) ){\n\t\t\t\t\treturn arrayToPattern(diacritics[l]);\n\t\t\t\t}\n\t\t\t\treturn l;\n\t\t\t});\n\t\t\t\n\t\t\treturn arrayToPattern(sub_pat,'');\n\t\t});\n\t\t\n\t\tdiacritic_patterns[latin] = arrayToPattern(pattern);\t\t\n\t});\n\t\t\t\n\treturn diacritic_patterns;\n}\n\n/**\n * Expand a regular expression pattern to include diacritics\n * \teg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/\n *\n */\nexport const diacriticRegexPoints = (regex:string):string => {\n\n\tif( diacritic_patterns === undefined ){\n\t\tdiacritic_patterns = generateDiacritics();\n\t}\n\t\n\tconst decomposed\t\t= regex.normalize('NFKD').toLowerCase();\n\t\n\treturn decomposed.split(latin_pat).map((part:string)=>{\n\t\t\n\t\tif( part == '' ){\n\t\t\treturn '';\n\t\t}\n\t\t\n\t\t// \"ffl\" or \"ffl\"\n\t\tconst no_accent = asciifold(part);\t\t\t\t\n\t\tif( diacritic_patterns.hasOwnProperty(no_accent) ){\n\t\t\treturn diacritic_patterns[no_accent];\n\t\t}\n\t\t\n\t\t// 'أهلا' (\\u{623}\\u{647}\\u{644}\\u{627}) or 'أهلا' (\\u{627}\\u{654}\\u{647}\\u{644}\\u{627})\n\t\tconst composed_part = part.normalize('NFC');\n\t\tif( composed_part != part ){\n\t\t\treturn arrayToPattern([part,composed_part]);\n\t\t}\n\t\t\t\t\n\t\treturn part;\n\t}).join('');\n\t\n}\n","\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport { asciifold } from './diacritics.ts';\n\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport * as T from './types.ts';\n\n\n/**\n * A property getter resolving dot-notation\n * @param {Object} obj The root object to fetch property on\n * @param {String} name The optionally dotted property name to fetch\n * @return {Object} The resolved property value\n */\nexport const getAttr = (obj:{[key:string]:any}, name:string ) => {\n if (!obj ) return;\n return obj[name];\n};\n\n/**\n * A property getter resolving dot-notation\n * @param {Object} obj The root object to fetch property on\n * @param {String} name The optionally dotted property name to fetch\n * @return {Object} The resolved property value\n */\nexport const getAttrNesting = (obj:{[key:string]:any}, name:string ) => {\n if (!obj ) return;\n var part, names = name.split(\".\");\n\twhile( (part = names.shift()) && (obj = obj[part]));\n return obj;\n};\n\n/**\n * Calculates how close of a match the\n * given value is against a search token.\n *\n */\nexport const scoreValue = (value:string, token:T.Token, weight:number ):number => {\n\tvar score, pos;\n\n\tif (!value) return 0;\n\n\tvalue = value + '';\n\tpos = value.search(token.regex);\n\tif (pos === -1) return 0;\n\n\tscore = token.string.length / value.length;\n\tif (pos === 0) score += 0.5;\n\n\treturn score * weight;\n};\n\n/**\n *\n * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error\n */\nexport const escape_regex = (str:string):string => {\t\n\treturn (str + '').replace(/([\\$\\(\\)\\*\\+\\.\\?\\[\\]\\^\\{\\|\\}\\\\])/gu, '\\\\$1');\n};\n\n\n/**\n * Cast object property to an array if it exists and has a value\n *\n */\nexport const propToArray = (obj:{[key:string]:any}, key:string) => {\n\tvar value = obj[key];\n\t\n\tif( typeof value == 'function' ) return value;\n\t\n\tif( value && !Array.isArray(value) ){\n\t\tobj[key] = [value];\n\t}\n}\n\n\n/**\n * Iterates over arrays and hashes.\n *\n * ```\n * iterate(this.items, function(item, id) {\n * // invoked for each item\n * });\n * ```\n *\n */\nexport const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:number|string)=>any) => {\n\n\tif ( Array.isArray(object)) {\n\t\tobject.forEach(callback);\n\n\t}else{\n\n\t\tfor (var key in object) {\n\t\t\tif (object.hasOwnProperty(key)) {\n\t\t\t\tcallback(object[key], key);\n\t\t\t}\n\t\t}\n\t}\n};\n\n\n\nexport const cmp = (a:number|string, b:number|string) => {\n\tif (typeof a === 'number' && typeof b === 'number') {\n\t\treturn a > b ? 1 : (a < b ? -1 : 0);\n\t}\n\ta = asciifold(a + '').toLowerCase();\n\tb = asciifold(b + '').toLowerCase();\n\tif (a > b) return 1;\n\tif (b > a) return -1;\n\treturn 0;\n};\n","/**\n * sifter.js\n * Copyright (c) 2013–2020 Brian Reavis & contributors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this\n * file except in compliance with the License. You may obtain a copy of the License at:\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n * ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n *\n * @author Brian Reavis <brian@thirdroute.com>\n */\n\n // @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport { scoreValue, getAttr, getAttrNesting, escape_regex, propToArray, iterate, cmp } from './utils.ts';\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport { diacriticRegexPoints } from './diacritics.ts';\n// @ts-ignore TS2691 \"An import path cannot end with a '.ts' extension\"\nimport * as T from 'types.ts';\n\nexport default class Sifter{\n\n\tpublic items; // []|{};\n\tpublic settings: T.Settings;\n\n\t/**\n\t * Textually searches arrays and hashes of objects\n\t * by property (or multiple properties). Designed\n\t * specifically for autocomplete.\n\t *\n\t */\n\tconstructor(items:any, settings:T.Settings) {\n\t\tthis.items = items;\n\t\tthis.settings = settings || {diacritics: true};\n\t};\n\n\t/**\n\t * Splits a search string into an array of individual\n\t * regexps to be used to match results.\n\t *\n\t */\n\ttokenize(query:string, respect_word_boundaries?:boolean, weights?:T.Weights ):T.Token[] {\n\t\tif (!query || !query.length) return [];\n\n\t\tconst tokens:T.Token[]\t= [];\n\t\tconst words\t\t\t\t= query.split(/\\s+/);\n\t\tvar field_regex:RegExp;\n\n\t\tif( weights ){\n\t\t\tfield_regex = new RegExp( '^('+ Object.keys(weights).map(escape_regex).join('|')+')\\:(.*)$');\n\t\t}\n\n\t\twords.forEach((word:string) => {\n\t\t\tlet field_match;\n\t\t\tlet field:null|string\t= null;\n\t\t\tlet regex:null|string\t= null;\n\n\t\t\t// look for \"field:query\" tokens\n\t\t\tif( field_regex && (field_match = word.match(field_regex)) ){\n\t\t\t\tfield\t= field_match[1];\n\t\t\t\tword\t= field_match[2];\n\t\t\t}\n\n\t\t\tif( word.length > 0 ){\n\t\t\t\tregex = escape_regex(word);\n\t\t\t\tif( this.settings.diacritics ){\n\t\t\t\t\tregex = diacriticRegexPoints(regex);\n\t\t\t\t}\n\t\t\t\tif( respect_word_boundaries ) regex = \"\\\\b\"+regex;\n\t\t\t}\n\n\t\t\ttokens.push({\n\t\t\t\tstring : word,\n\t\t\t\tregex : regex ? new RegExp(regex,'iu') : null,\n\t\t\t\tfield : field,\n\t\t\t});\n\t\t});\n\n\t\treturn tokens;\n\t};\n\n\n\t/**\n\t * Returns a function to be used to score individual results.\n\t *\n\t * Good matches will have a higher score than poor matches.\n\t * If an item is not a match, 0 will be returned by the function.\n\t *\n\t * @returns {function}\n\t */\n\tgetScoreFunction(query:string, options:T.Options ){\n\t\tvar search = this.prepareSearch(query, options);\n\t\treturn this._getScoreFunction(search);\n\t}\n\n\t_getScoreFunction(search:T.PrepareObj ){\n\t\tconst tokens\t\t= search.tokens,\n\t\ttoken_count\t\t\t= tokens.length;\n\n\t\tif (!token_count) {\n\t\t\treturn function() { return 0; };\n\t\t}\n\n\t\tconst fields\t= search.options.fields,\n\t\tweights\t\t\t= search.weights,\n\t\tfield_count\t\t= fields.length,\n\t\tgetAttrFn\t\t= search.getAttrFn;\n\n\t\tif (!field_count) {\n\t\t\treturn function() { return 1; };\n\t\t}\n\n\n\t\t/**\n\t\t * Calculates the score of an object\n\t\t * against the search query.\n\t\t *\n\t\t */\n\t\tconst scoreObject = (function() {\n\n\n\t\t\tif (field_count === 1) {\n\t\t\t\treturn function(token:T.Token, data:{}) {\n\t\t\t\t\tconst field = fields[0].field;\n\t\t\t\t\treturn scoreValue(getAttrFn(data, field), token, weights[field]);\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn function(token:T.Token, data:{}) {\n\t\t\t\tvar sum = 0;\n\n\t\t\t\t// is the token specific to a field?\n\t\t\t\tif( token.field ){\n\n\t\t\t\t\tconst value = getAttrFn(data, token.field);\n\n\t\t\t\t\tif( !token.regex && value ){\n\t\t\t\t\t\tsum += (1/field_count);\n\t\t\t\t\t}else{\n\t\t\t\t\t\tsum += scoreValue(value, token, 1);\n\t\t\t\t\t}\n\n\n\n\t\t\t\t}else{\n\t\t\t\t\titerate(weights, (weight:number, field:string) => {\n\t\t\t\t\t\tsum += scoreValue(getAttrFn(data, field), token, weight);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn sum / field_count;\n\t\t\t};\n\t\t})();\n\n\t\tif (token_count === 1) {\n\t\t\treturn function(data:{}) {\n\t\t\t\treturn scoreObject(tokens[0], data);\n\t\t\t};\n\t\t}\n\n\t\tif (search.options.conjunction === 'and') {\n\t\t\treturn function(data:{}) {\n\t\t\t\tvar i = 0, score, sum = 0;\n\t\t\t\tfor (; i < token_count; i++) {\n\t\t\t\t\tscore = scoreObject(tokens[i], data);\n\t\t\t\t\tif (score <= 0) return 0;\n\t\t\t\t\tsum += score;\n\t\t\t\t}\n\t\t\t\treturn sum / token_count;\n\t\t\t};\n\t\t} else {\n\t\t\treturn function(data:{}) {\n\t\t\t\tvar sum = 0;\n\t\t\t\titerate(tokens,(token:T.Token)=>{\n\t\t\t\t\tsum += scoreObject(token, data);\n\t\t\t\t});\n\t\t\t\treturn sum / token_count;\n\t\t\t};\n\t\t}\n\t};\n\n\t/**\n\t * Returns a function that can be used to compare two\n\t * results, for sorting purposes. If no sorting should\n\t * be performed, `null` will be returned.\n\t *\n\t * @return function(a,b)\n\t */\n\tgetSortFunction(query:string, options:T.Options) {\n\t\tvar search = this.prepareSearch(query, options);\n\t\treturn this._getSortFunction(search);\n\t}\n\n\t_getSortFunction(search:T.PrepareObj){\n\t\tvar i, n, implicit_score;\n\n\t\tconst self\t= this,\n\t\toptions\t\t= search.options,\n\t\tsort\t\t= (!search.query && options.sort_empty) ? options.sort_empty : options.sort,\n\t\tsort_flds:T.Sort[]\t\t= [],\n\t\tmultipliers:number[]\t= [];\n\n\n\t\tif( typeof sort == 'function' ){\n\t\t\treturn sort.bind(this);\n\t\t}\t\t\t\n\n\t\t/**\n\t\t * Fetches the specified sort field value\n\t\t * from a search result item.\n\t\t *\n\t\t */\n\t\tconst get_field = function(name:string, result:T.ResultItem):string|number {\n\t\t\tif (name === '$score') return result.score;\n\t\t\treturn search.getAttrFn(self.items[result.id], name);\n\t\t};\n\n\t\t// parse options\n\t\tif (sort) {\n\t\t\tfor (i = 0, n = sort.length; i < n; i++) {\n\t\t\t\tif (search.query || sort[i].field !== '$score') {\n\t\t\t\t\tsort_flds.push(sort[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// the \"$score\" field is implied to be the primary\n\t\t// sort field, unless it's manually specified\n\t\tif (search.query) {\n\t\t\timplicit_score = true;\n\t\t\tfor (i = 0, n = sort_flds.length; i < n; i++) {\n\t\t\t\tif (sort_flds[i].field === '$score') {\n\t\t\t\t\timplicit_score = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (implicit_score) {\n\t\t\t\tsort_flds.unshift({field: '$score', direction: 'desc'});\n\t\t\t}\n\t\t} else {\n\t\t\tfor (i = 0, n = sort_flds.length; i < n; i++) {\n\t\t\t\tif (sort_flds[i].field === '$score') {\n\t\t\t\t\tsort_flds.splice(i, 1);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0, n = sort_flds.length; i < n; i++) {\n\t\t\tmultipliers.push(sort_flds[i].direction === 'desc' ? -1 : 1);\n\t\t}\n\n\t\t// build function\n\t\tconst sort_flds_count = sort_flds.length;\n\t\tif (!sort_flds_count) {\n\t\t\treturn null;\n\t\t} else if (sort_flds_count === 1) {\n\t\t\tconst sort_fld = sort_flds[0].field;\n\t\t\tconst multiplier = multipliers[0];\n\t\t\treturn function(a:T.ResultItem, b:T.ResultItem) {\n\t\t\t\treturn multiplier * cmp(\n\t\t\t\t\tget_field(sort_fld, a),\n\t\t\t\t\tget_field(sort_fld, b)\n\t\t\t\t);\n\t\t\t};\n\t\t} else {\n\t\t\treturn function(a:T.ResultItem, b:T.ResultItem) {\n\t\t\t\tvar i, result, field;\n\t\t\t\tfor (i = 0; i < sort_flds_count; i++) {\n\t\t\t\t\tfield = sort_flds[i].field;\n\t\t\t\t\tresult = multipliers[i] * cmp(\n\t\t\t\t\t\tget_field(field, a),\n\t\t\t\t\t\tget_field(field, b)\n\t\t\t\t\t);\n\t\t\t\t\tif (result) return result;\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t};\n\t\t}\n\t};\n\n\t/**\n\t * Parses a search query and returns an object\n\t * with tokens and fields ready to be populated\n\t * with results.\n\t *\n\t */\n\tprepareSearch(query:string, optsUser:Partial<T.Options>):T.PrepareObj {\n\t\tconst weights:T.Weights = {};\n\t\tvar options\t\t= Object.assign({},optsUser);\n\n\t\tpropToArray(options,'sort');\n\t\tpropToArray(options,'sort_empty');\n\n\t\t// convert fields to new format\n\t\tif( options.fields ){\n\t\t\tpropToArray(options,'fields');\n\t\t\tconst fields:T.Field[] = [];\n\t\t\toptions.fields.forEach((field:string|T.Field) => {\n\t\t\t\tif( typeof field == 'string' ){\n\t\t\t\t\tfield = {field:field,weight:1};\n\t\t\t\t}\n\t\t\t\tfields.push(field);\n\t\t\t\tweights[field.field] = ('weight' in field) ? field.weight : 1;\n\t\t\t});\n\t\t\toptions.fields = fields;\n\t\t}\n\n\n\t\treturn {\n\t\t\toptions\t\t: options,\n\t\t\tquery\t\t: query.toLowerCase().trim(),\n\t\t\ttokens\t\t: this.tokenize(query, options.respect_word_boundaries, weights),\n\t\t\ttotal\t\t: 0,\n\t\t\titems\t\t: [],\n\t\t\tweights\t\t: weights,\n\t\t\tgetAttrFn\t: (options.nesting) ? getAttrNesting : getAttr,\n\t\t};\n\t};\n\n\t/**\n\t * Searches through all items and returns a sorted array of matches.\n\t *\n\t */\n\tsearch(query:string, options:T.Options) : T.PrepareObj {\n\t\tvar self = this, score, search:T.PrepareObj;\n\n\t\tsearch = this.prepareSearch(query, options);\n\t\toptions = search.options;\n\t\tquery = search.query;\n\n\t\t// generate result scoring function\n\t\tconst fn_score = options.score || self._getScoreFunction(search);\n\n\t\t// perform search and sort\n\t\tif (query.length) {\n\t\t\titerate(self.items, (item:T.ResultItem, id:string|number) => {\n\t\t\t\tscore = fn_score(item);\n\t\t\t\tif (options.filter === false || score > 0) {\n\t\t\t\t\tsearch.items.push({'score': score, 'id': id});\n\t\t\t\t}\n\t\t\t});\n\t\t} else {\n\t\t\titerate(self.items, (_:T.ResultItem, id:string|number) => {\n\t\t\t\tsearch.items.push({'score': 1, 'id': id});\n\t\t\t});\n\t\t}\n\n\t\tconst fn_sort = self._getSortFunction(search);\n\t\tif (fn_sort) search.items.sort(fn_sort);\n\n\t\t// apply limits\n\t\tsearch.total = search.items.length;\n\t\tif (typeof options.limit === 'number') {\n\t\t\tsearch.items = search.items.slice(0, options.limit);\n\t\t}\n\n\t\treturn search;\n\t};\n}\n"],"names":["latin_pat","accent_pat","accent_reg","RegExp","diacritic_patterns","latin_convert","convert_pat","Object","keys","join","code_points","asciifold","str","normalize","replace","toLowerCase","foreignletter","arrayToPattern","chars","glue","length","longest","forEach","a","Math","max","allSubstrings","input","result","substring","subresult","tmp","slice","charAt","push","unshift","generateDiacritics","diacritics","code_range","i","diacritic","String","fromCharCode","latin","patt","match","latin_chars","sort","b","substrings","pattern","map","sub_pat","l","hasOwnProperty","diacriticRegexPoints","regex","undefined","decomposed","split","part","no_accent","composed_part","getAttr","obj","name","getAttrNesting","names","shift","scoreValue","value","token","weight","score","pos","search","string","escape_regex","propToArray","key","Array","isArray","iterate","object","callback","cmp","Sifter","constructor","items","settings","tokenize","query","respect_word_boundaries","weights","tokens","words","field_regex","word","field_match","field","getScoreFunction","options","prepareSearch","_getScoreFunction","token_count","fields","field_count","getAttrFn","scoreObject","data","sum","conjunction","getSortFunction","_getSortFunction","n","implicit_score","self","sort_empty","sort_flds","multipliers","bind","get_field","id","direction","splice","sort_flds_count","sort_fld","multiplier","optsUser","assign","trim","total","nesting","fn_score","item","filter","_","fn_sort","limit"],"mappings":";;;;;;;CAGA;CAEA,IAAIA,SAAJ;CACA,MAAMC,UAAU,GAAG,8BAAnB;;CACA,MAAMC,UAAU,GAAG,IAAIC,MAAJ,CAAWF,UAAX,EAAsB,GAAtB,CAAnB;CACA,IAAIG,kBAAJ;CAEA,MAAMC,aAA4B,GAAG;CACpC,OAAK,IAD+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KAAP,CAAatD,IAAb,CAAkB;CAAC,mBAAS,CAAV;CAAa,gBAAMwF;CAAnB,SAAlB;CACA,OAFM,CAAP;CAGA;;CAED,UAAMe,OAAO,GAAGrB,IAAI,CAACH,gBAAL,CAAsBtC,MAAtB,CAAhB;;CACA,QAAI8D,OAAJ,EAAa9D,MAAM,CAACa,KAAP,CAAazC,IAAb,CAAkB0F,OAAlB,EAzByC;;CA4BtD9D,IAAAA,MAAM,CAACwD,KAAP,GAAexD,MAAM,CAACa,KAAP,CAAapE,MAA5B;;CACA,QAAI,OAAOiF,OAAO,CAACqC,KAAf,KAAyB,QAA7B,EAAuC;CACtC/D,MAAAA,MAAM,CAACa,KAAP,GAAeb,MAAM,CAACa,KAAP,CAAaxD,KAAb,CAAmB,CAAnB,EAAsBqE,OAAO,CAACqC,KAA9B,CAAf;CACA;;CAED,WAAO/D,MAAP;CACA;;CAlVyB;;;;;;;;"}
|
package/dist/umd/sifter.min.js
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).sifter=t()}(this,(function(){"use strict"
|
|
2
|
-
var e
|
|
3
|
-
const t=
|
|
4
|
-
var
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
var e
|
|
3
|
+
const t="[̀-ͯ·ʾ]",r=new RegExp(t,"g")
|
|
4
|
+
var n
|
|
5
|
+
const i={"æ":"ae","ⱥ":"a","ø":"o"},o=new RegExp(Object.keys(i).join("|"),"g"),s=[[67,67],[160,160],[192,438],[452,652],[961,961],[1019,1019],[1083,1083],[1281,1289],[1984,1984],[5095,5095],[7429,7441],[7545,7549],[7680,7935],[8580,8580],[9398,9449],[11360,11391],[42792,42793],[42802,42851],[42873,42897],[42912,42922],[64256,64260],[65313,65338],[65345,65370]],c=e=>e.normalize("NFKD").replace(r,"").toLowerCase().replace(o,(function(e){return i[e]})),u=(e,t="|")=>{if(1==e.length)return e[0]
|
|
6
|
+
var r=1
|
|
7
|
+
return e.forEach((e=>{r=Math.max(r,e.length)})),1==r?"["+e.join("")+"]":"(?:"+e.join(t)+")"},f=e=>{if(1===e.length)return[[e]]
|
|
8
|
+
var t=[]
|
|
9
|
+
return f(e.substring(1)).forEach((function(r){var n=r.slice(0)
|
|
10
|
+
n[0]=e.charAt(0)+n[0],t.push(n),(n=r.slice(0)).unshift(e.charAt(0)),t.push(n)})),t},a=t=>{void 0===n&&(n=(()=>{var t={}
|
|
11
|
+
s.forEach((e=>{for(let n=e[0];n<=e[1];n++){let e=String.fromCharCode(n),i=c(e)
|
|
12
|
+
if(i!=e.toLowerCase()){i in t||(t[i]=[i])
|
|
13
|
+
var r=new RegExp(u(t[i]),"iu")
|
|
14
|
+
e.match(r)||t[i].push(e)}}}))
|
|
15
|
+
var r=Object.keys(t)
|
|
16
|
+
r=r.sort(((e,t)=>t.length-e.length)),e=new RegExp("("+u(r)+"[̀-ͯ·ʾ]*)","g")
|
|
17
|
+
var n={}
|
|
18
|
+
return r.sort(((e,t)=>e.length-t.length)).forEach((e=>{var r=f(e).map((e=>(e=e.map((e=>t.hasOwnProperty(e)?u(t[e]):e)),u(e,""))))
|
|
19
|
+
n[e]=u(r)})),n})())
|
|
20
|
+
return t.normalize("NFKD").toLowerCase().split(e).map((e=>{if(""==e)return""
|
|
21
|
+
const t=c(e)
|
|
22
|
+
if(n.hasOwnProperty(t))return n[t]
|
|
23
|
+
const r=e.normalize("NFC")
|
|
24
|
+
return r!=e?u([e,r]):e})).join("")},l=(e,t)=>{if(e)return e[t]},h=(e,t)=>{if(e){for(var r,n=t.split(".");(r=n.shift())&&(e=e[r]););return e}},g=(e,t,r)=>{var n,i
|
|
25
|
+
return e?-1===(i=(e+="").search(t.regex))?0:(n=t.string.length/e.length,0===i&&(n+=.5),n*r):0},p=e=>(e+"").replace(/([\$\(-\+\.\?\[-\^\{-\}])/g,"\\$1"),d=(e,t)=>{var r=e[t]
|
|
26
|
+
if("function"==typeof r)return r
|
|
27
|
+
r&&!Array.isArray(r)&&(e[t]=[r])},m=(e,t)=>{if(Array.isArray(e))e.forEach(t)
|
|
28
|
+
else for(var r in e)e.hasOwnProperty(r)&&t(e[r],r)},y=(e,t)=>"number"==typeof e&&"number"==typeof t?e>t?1:e<t?-1:0:(e=c(e+"").toLowerCase())>(t=c(t+"").toLowerCase())?1:t>e?-1:0
|
|
13
29
|
|
|
14
30
|
;/**
|
|
15
31
|
* sifter.js
|
|
@@ -27,40 +43,42 @@ else for(var r in e)e.hasOwnProperty(r)&&t(e[r],r)},l=(e,r)=>"number"==typeof e&
|
|
|
27
43
|
* @author Brian Reavis <brian@thirdroute.com>
|
|
28
44
|
*/
|
|
29
45
|
return class{constructor(e,t){this.items=void 0,this.settings=void 0,this.items=e,this.settings=t||{diacritics:!0}}tokenize(e,t,r){if(!e||!e.length)return[]
|
|
30
|
-
const
|
|
31
|
-
var
|
|
32
|
-
return r&&(
|
|
33
|
-
|
|
46
|
+
const n=[],i=e.split(/\s+/)
|
|
47
|
+
var o
|
|
48
|
+
return r&&(o=new RegExp("^("+Object.keys(r).map(p).join("|")+"):(.*)$")),i.forEach((e=>{let r,i=null,s=null
|
|
49
|
+
o&&(r=e.match(o))&&(i=r[1],e=r[2]),e.length>0&&(s=p(e),this.settings.diacritics&&(s=a(s)),t&&(s="\\b"+s)),n.push({string:e,regex:s?new RegExp(s,"iu"):null,field:i})})),n}getScoreFunction(e,t){var r=this.prepareSearch(e,t)
|
|
34
50
|
return this._getScoreFunction(r)}_getScoreFunction(e){const t=e.tokens,r=t.length
|
|
35
51
|
if(!r)return function(){return 0}
|
|
36
|
-
const n=e.options.fields,i=e.weights,o=n.length,
|
|
52
|
+
const n=e.options.fields,i=e.weights,o=n.length,s=e.getAttrFn
|
|
37
53
|
if(!o)return function(){return 1}
|
|
38
|
-
const
|
|
39
|
-
return s(
|
|
40
|
-
if(e.field){const n=
|
|
41
|
-
!e.regex&&n?r+=1/o:r+=
|
|
54
|
+
const c=1===o?function(e,t){const r=n[0].field
|
|
55
|
+
return g(s(t,r),e,i[r])}:function(e,t){var r=0
|
|
56
|
+
if(e.field){const n=s(t,e.field)
|
|
57
|
+
!e.regex&&n?r+=1/o:r+=g(n,e,1)}else m(i,((n,i)=>{r+=g(s(t,i),e,n)}))
|
|
42
58
|
return r/o}
|
|
43
|
-
return 1===r?function(e){return
|
|
59
|
+
return 1===r?function(e){return c(t[0],e)}:"and"===e.options.conjunction?function(e){for(var n,i=0,o=0;i<r;i++){if((n=c(t[i],e))<=0)return 0
|
|
44
60
|
o+=n}return o/r}:function(e){var n=0
|
|
45
|
-
return
|
|
61
|
+
return m(t,(t=>{n+=c(t,e)})),n/r}}getSortFunction(e,t){var r=this.prepareSearch(e,t)
|
|
46
62
|
return this._getSortFunction(r)}_getSortFunction(e){var t,r,n
|
|
47
|
-
const i=this,o=e.options,s=!e.query&&o.sort_empty?o.sort_empty:o.sort,c=[],u=[]
|
|
63
|
+
const i=this,o=e.options,s=!e.query&&o.sort_empty?o.sort_empty:o.sort,c=[],u=[]
|
|
64
|
+
if("function"==typeof s)return s.bind(this)
|
|
65
|
+
const f=function(t,r){return"$score"===t?r.score:e.getAttrFn(i.items[r.id],t)}
|
|
48
66
|
if(s)for(t=0,r=s.length;t<r;t++)(e.query||"$score"!==s[t].field)&&c.push(s[t])
|
|
49
67
|
if(e.query){for(n=!0,t=0,r=c.length;t<r;t++)if("$score"===c[t].field){n=!1
|
|
50
68
|
break}n&&c.unshift({field:"$score",direction:"desc"})}else for(t=0,r=c.length;t<r;t++)if("$score"===c[t].field){c.splice(t,1)
|
|
51
69
|
break}for(t=0,r=c.length;t<r;t++)u.push("desc"===c[t].direction?-1:1)
|
|
52
70
|
const a=c.length
|
|
53
71
|
if(a){if(1===a){const e=c[0].field,t=u[0]
|
|
54
|
-
return function(r,n){return t*
|
|
55
|
-
for(r=0;r<a;r++)if(i=c[r].field,n=u[r]*
|
|
56
|
-
return 0}}return null}prepareSearch(e,
|
|
57
|
-
var
|
|
58
|
-
if(
|
|
72
|
+
return function(r,n){return t*y(f(e,r),f(e,n))}}return function(e,t){var r,n,i
|
|
73
|
+
for(r=0;r<a;r++)if(i=c[r].field,n=u[r]*y(f(i,e),f(i,t)))return n
|
|
74
|
+
return 0}}return null}prepareSearch(e,t){const r={}
|
|
75
|
+
var n=Object.assign({},t)
|
|
76
|
+
if(d(n,"sort"),d(n,"sort_empty"),n.fields){d(n,"fields")
|
|
59
77
|
const e=[]
|
|
60
|
-
|
|
78
|
+
n.fields.forEach((t=>{"string"==typeof t&&(t={field:t,weight:1}),e.push(t),r[t.field]="weight"in t?t.weight:1})),n.fields=e}return{options:n,query:e.toLowerCase().trim(),tokens:this.tokenize(e,n.respect_word_boundaries,r),total:0,items:[],weights:r,getAttrFn:n.nesting?h:l}}search(e,t){var r,n,i=this
|
|
61
79
|
n=this.prepareSearch(e,t),t=n.options,e=n.query
|
|
62
80
|
const o=t.score||i._getScoreFunction(n)
|
|
63
|
-
e.length?
|
|
81
|
+
e.length?m(i.items,((e,i)=>{r=o(e),(!1===t.filter||r>0)&&n.items.push({score:r,id:i})})):m(i.items,((e,t)=>{n.items.push({score:1,id:t})}))
|
|
64
82
|
const s=i._getSortFunction(n)
|
|
65
83
|
return s&&n.items.sort(s),n.total=n.items.length,"number"==typeof t.limit&&(n.items=n.items.slice(0,t.limit)),n}}}))
|
|
66
84
|
//# sourceMappingURL=sifter.min.js.map
|