@orchidjs/sifter 0.8.2 → 0.9.2

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 (70) hide show
  1. package/README.md +27 -5
  2. package/dist/cjs/diacritics.js +44 -31
  3. package/dist/cjs/diacritics.js.map +1 -1
  4. package/dist/cjs/sifter.js +9 -4
  5. package/dist/cjs/sifter.js.map +1 -1
  6. package/dist/cjs/utils.js +1 -0
  7. package/dist/cjs/utils.js.map +1 -1
  8. package/dist/esm/diacritics.js +44 -31
  9. package/dist/esm/diacritics.js.map +1 -1
  10. package/dist/esm/sifter.js +9 -4
  11. package/dist/esm/sifter.js.map +1 -1
  12. package/dist/esm/utils.js +1 -0
  13. package/dist/esm/utils.js.map +1 -1
  14. package/dist/types/diacritics.d.ts +2 -7
  15. package/dist/types/sifter.d.ts +3 -3
  16. package/dist/types/types.d.ts +10 -8
  17. package/dist/types/utils.d.ts +1 -1
  18. package/dist/umd/sifter.js +51 -34
  19. package/dist/umd/sifter.js.map +1 -1
  20. package/dist/umd/sifter.min.js +32 -30
  21. package/dist/umd/sifter.min.js.map +1 -1
  22. package/lib/diacritics.ts +63 -215
  23. package/lib/sifter.ts +9 -4
  24. package/lib/types.ts +12 -8
  25. package/lib/utils.ts +4 -1
  26. package/package.json +11 -6
  27. package/.config/babel.config.json +0 -17
  28. package/.config/rollup.config.js +0 -95
  29. package/.config/tsconfig.json +0 -16
  30. package/.travis.yml +0 -9
  31. package/Makefile +0 -27
  32. package/build/cjs/diacritics.js +0 -173
  33. package/build/cjs/diacritics.js.map +0 -1
  34. package/build/cjs/sifter.js +0 -372
  35. package/build/cjs/sifter.js.map +0 -1
  36. package/build/cjs/utils.js +0 -113
  37. package/build/cjs/utils.js.map +0 -1
  38. package/build/esm/diacritics.js +0 -164
  39. package/build/esm/diacritics.js.map +0 -1
  40. package/build/esm/sifter.js +0 -370
  41. package/build/esm/sifter.js.map +0 -1
  42. package/build/esm/utils.js +0 -103
  43. package/build/esm/utils.js.map +0 -1
  44. package/build/umd/sifter.js +0 -634
  45. package/build/umd/sifter.js.map +0 -1
  46. package/build/umd/sifter.min.js +0 -81
  47. package/build/umd/sifter.min.js.map +0 -1
  48. package/coverage/clover.xml +0 -258
  49. package/coverage/coverage-final.json +0 -4
  50. package/coverage/lcov-report/base.css +0 -224
  51. package/coverage/lcov-report/block-navigation.js +0 -79
  52. package/coverage/lcov-report/diacritics.ts.html +0 -1133
  53. package/coverage/lcov-report/favicon.png +0 -0
  54. package/coverage/lcov-report/index.html +0 -141
  55. package/coverage/lcov-report/prettify.css +0 -1
  56. package/coverage/lcov-report/prettify.js +0 -2
  57. package/coverage/lcov-report/sifter.ts.html +0 -1157
  58. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  59. package/coverage/lcov-report/sorter.js +0 -170
  60. package/coverage/lcov-report/utils.ts.html +0 -410
  61. package/coverage/lcov.info +0 -505
  62. package/release.sh +0 -119
  63. package/test/diacritics.js +0 -64
  64. package/test/getScoreFunction.js +0 -55
  65. package/test/prepareSearch.js +0 -40
  66. package/test/search.js +0 -335
  67. package/test/sorting.js +0 -193
  68. package/test/tokenize.js +0 -63
  69. package/test/utils.js +0 -28
  70. package/x-test.js +0 -125
package/lib/diacritics.ts CHANGED
@@ -1,11 +1,14 @@
1
1
 
2
+ // @ts-ignore TS2691 "An import path cannot end with a '.ts' extension"
3
+ import { escape_regex } from './utils.ts';
4
+
2
5
  type TDiacraticList = {[key:string]:string};
3
6
 
4
7
  // https://github.com/andrewrk/node-diacritics/blob/master/index.js
5
8
 
6
9
  var latin_pat:RegExp;
7
10
  const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}]'; // \u{2bc}
8
- const accent_reg = new RegExp(accent_pat,'g');
11
+ const accent_reg = new RegExp(accent_pat,'gu');
9
12
  var diacritic_patterns:TDiacraticList;
10
13
 
11
14
  const latin_convert:TDiacraticList = {
@@ -14,139 +17,9 @@ const latin_convert:TDiacraticList = {
14
17
  'ø': 'o',
15
18
  };
16
19
 
17
- const convert_pat = new RegExp(Object.keys(latin_convert).join('|'),'g');
18
-
19
-
20
- export const DIACRITICS:TDiacraticList = {
21
- " ":" ",
22
- 0:"߀",
23
- A:"ⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ",
24
- AA:"Ꜳ",
25
- AE:"ÆǼǢ",
26
- AO:"Ꜵ",
27
- AU:"Ꜷ",
28
- AV:"ꜸꜺ",
29
- AY:"Ꜽ",
30
- B:"ⒷBḂḄḆɃƁ",
31
- C:"ⒸCꜾḈĆCĈĊČÇƇȻ",
32
- D:"ⒹDḊĎḌḐḒḎĐƊƉᴅꝹ",
33
- Dh:"Ð",
34
- DZ:"DZDŽ",
35
- Dz:"DzDž",
36
- E:"ɛⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎᴇ",
37
- F:"ꝼⒻFḞƑꝻ",
38
- G:"ⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾɢ",
39
- H:"ⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ",
40
- I:"ⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ",
41
- J:"ⒿJĴɈȷ",
42
- K:"ⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ",
43
- L:"ⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ",
44
- LJ:"LJ",
45
- Lj:"Lj",
46
- M:"ⓂMḾṀṂⱮƜϻ",
47
- N:"ꞤȠⓃNǸŃÑṄŇṆŅṊṈƝꞐᴎ",
48
- NJ:"NJ",
49
- Nj:"Nj",
50
- O:"ⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ",
51
- OE:"Œ",
52
- OI:"Ƣ",
53
- OO:"Ꝏ",
54
- OU:"Ȣ",
55
- P:"ⓅPṔṖƤⱣꝐꝒꝔ",
56
- Q:"ⓆQꝖꝘɊ",
57
- R:"ⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ",
58
- S:"ⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ",
59
- T:"ⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ",
60
- Th:"Þ",
61
- TZ:"Ꜩ",
62
- U:"ⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ",
63
- V:"ⓋVṼṾƲꝞɅ",
64
- VY:"Ꝡ",
65
- W:"ⓌWẀẂŴẆẄẈⱲ",
66
- X:"ⓍXẊẌ",
67
- Y:"ⓎYỲÝŶỸȲẎŸỶỴƳɎỾ",
68
- Z:"ⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ",
69
- a:"ⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑ",
70
- aa:"ꜳ",
71
- ae:"æǽǣ",
72
- ao:"ꜵ",
73
- au:"ꜷ",
74
- av:"ꜹꜻ",
75
- ay:"ꜽ",
76
- b:"ⓑbḃḅḇƀƃɓƂ",
77
- c:"cⓒćĉċčçḉƈȼꜿↄ",
78
- d:"ⓓdḋďḍḑḓḏđƌɖɗƋᏧԁꞪ",
79
- dh:"ð",
80
- dz:"dzdž",
81
- e:"ⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇǝ",
82
- f:"ⓕfḟƒ",
83
- ff:"ff",
84
- fi:"fi",
85
- fl:"fl",
86
- ffi:"ffi",
87
- ffl:"ffl",
88
- g:"ⓖgǵĝḡğġǧģǥɠꞡꝿᵹ",
89
- h:"ⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ",
90
- hv:"ƕ",
91
- i:"ⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı",
92
- j:"ⓙjĵǰɉ",
93
- k:"ⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ",
94
- l:"ⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇɭ",
95
- lj:"lj",
96
- m:"ⓜmḿṁṃɱɯ",
97
- n:"ⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥлԉ",
98
- nj:"nj",
99
- o:"ⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿꝋꝍɵɔᴑ",
100
- oe:"œ",
101
- oi:"ƣ",
102
- oo:"ꝏ",
103
- ou:"ȣ",
104
- p:"ⓟpṕṗƥᵽꝑꝓꝕρ",
105
- q:"ⓠqɋꝗꝙ",
106
- r:"ⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ",
107
- s:"ⓢsśṥŝṡšṧṣṩșşȿꞩꞅẛʂ",
108
- ss:"ß",
109
- t:"ⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ",
110
- th:"þ",
111
- tz:"ꜩ",
112
- u:"ⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ",
113
- v:"ⓥvṽṿʋꝟʌ",
114
- vy:"ꝡ",
115
- w:"ⓦwẁẃŵẇẅẘẉⱳ",
116
- x:"ⓧxẋẍ",
117
- y:"ⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ",
118
- z:"ⓩzźẑżžẓẕƶȥɀⱬꝣ"
119
- }
20
+ const convert_pat = new RegExp(Object.keys(latin_convert).join('|'),'gu');
120
21
 
121
- /**
122
- * code points generated from toCodePoints();
123
- * removed 65339 to 65345
124
- */
125
- export const code_points = [
126
- [ 67, 67 ],
127
- [ 160, 160 ],
128
- [ 192, 438 ],
129
- [ 452, 652 ],
130
- [ 961, 961 ],
131
- [ 1019, 1019 ],
132
- [ 1083, 1083 ],
133
- [ 1281, 1289 ],
134
- [ 1984, 1984 ],
135
- [ 5095, 5095 ],
136
- [ 7429, 7441 ],
137
- [ 7545, 7549 ],
138
- [ 7680, 7935 ],
139
- [ 8580, 8580 ],
140
- [ 9398, 9449 ],
141
- [ 11360, 11391 ],
142
- [ 42792, 42793 ],
143
- [ 42802, 42851 ],
144
- [ 42873, 42897 ],
145
- [ 42912, 42922 ],
146
- [ 64256, 64260 ],
147
- [ 65313, 65338 ],
148
- [ 65345, 65370 ]
149
- ];
22
+ const code_points:[[number,number]] = [[ 0, 65535 ]];
150
23
 
151
24
  /**
152
25
  * Remove accents
@@ -163,47 +36,6 @@ export const asciifold = (str:string):string => {
163
36
  });
164
37
  };
165
38
 
166
-
167
- /**
168
- * Convert list of diacritics to array of code points
169
- *
170
- */
171
- // @ts-ignore
172
- function toCodePoints(tolerance=8){
173
- var char_codes:number[] = [];
174
-
175
- for( let letter in DIACRITICS ){
176
- let _diacritics = DIACRITICS[letter];
177
- for( let n = 0; n < _diacritics.length; n++ ){
178
- var code_point = _diacritics.codePointAt(n);
179
- if( code_point ) char_codes.push( code_point );
180
- }
181
- }
182
-
183
- //https://stackoverflow.com/questions/40431572/is-there-a-simple-way-to-group-js-array-values-by-range
184
- char_codes.sort((a, b) => a - b);
185
- var accumulator: number[][] = [];
186
- char_codes.reduce(function (accumulator, currentValue, index, source) {
187
-
188
- if( !index ){
189
- accumulator.push( [currentValue,currentValue] );
190
-
191
- }else if( currentValue - source[index - 1] > tolerance ){
192
- accumulator.push( [currentValue,currentValue] );
193
-
194
- }else{
195
-
196
- let range = accumulator.pop();
197
- if( range ){
198
- accumulator.push( [range[0],currentValue]);
199
- }
200
- }
201
-
202
- return accumulator;
203
- }, accumulator);
204
-
205
- }
206
-
207
39
  /**
208
40
  * Convert array of strings to a regular expression
209
41
  * ex ['ab','a'] => (?:ab|a)
@@ -211,11 +43,11 @@ function toCodePoints(tolerance=8){
211
43
  *
212
44
  */
213
45
  export const arrayToPattern = (chars:string[],glue:string='|'):string =>{
214
-
46
+
215
47
  if( chars.length == 1 ){
216
48
  return chars[0];
217
49
  }
218
-
50
+
219
51
  var longest = 1;
220
52
  chars.forEach((a)=>{longest = Math.max(longest,a.length)});
221
53
 
@@ -223,7 +55,12 @@ export const arrayToPattern = (chars:string[],glue:string='|'):string =>{
223
55
  return '['+chars.join('')+']';
224
56
  }
225
57
 
226
- return '(?:'+chars.join(glue)+')';
58
+ return '(?:'+chars.join(glue)+')';
59
+ };
60
+
61
+ export const escapeToPattern = (chars:string[]):string =>{
62
+ const escaped = chars.map((diacritic) => escape_regex(diacritic));
63
+ return arrayToPattern(escaped);
227
64
  };
228
65
 
229
66
  /**
@@ -245,7 +82,7 @@ export const allSubstrings = (input:string):string[][] => {
245
82
  tmp.unshift(input.charAt(0));
246
83
  result.push(tmp);
247
84
  });
248
-
85
+
249
86
  return result;
250
87
  }
251
88
 
@@ -253,13 +90,13 @@ export const allSubstrings = (input:string):string[][] => {
253
90
  * Generate a list of diacritics from the list of code points
254
91
  *
255
92
  */
256
- export const generateDiacritics = ():TDiacraticList => {
93
+ export const generateDiacritics = (code_points:[[number,number]]):TDiacraticList => {
257
94
 
258
95
  var diacritics:{[key:string]:string[]} = {};
259
96
  code_points.forEach((code_range)=>{
260
97
 
261
98
  for(let i = code_range[0]; i <= code_range[1]; i++){
262
-
99
+
263
100
  let diacritic = String.fromCharCode(i);
264
101
  let latin = asciifold(diacritic);
265
102
 
@@ -267,50 +104,67 @@ export const generateDiacritics = ():TDiacraticList => {
267
104
  continue;
268
105
  }
269
106
 
107
+ // skip when latin is a string longer than 3 characters long
108
+ // bc the resulting regex patterns will be long
109
+ // eg:
110
+ // latin صلى الله عليه وسلم length 18 code point 65018
111
+ // latin جل جلاله length 8 code point 65019
112
+ if( latin.length > 3 ){
113
+ continue;
114
+ }
115
+
270
116
  if( !(latin in diacritics) ){
271
117
  diacritics[latin] = [latin];
272
118
  }
273
-
274
- var patt = new RegExp( arrayToPattern(diacritics[latin]),'iu');
119
+
120
+ var patt = new RegExp( escapeToPattern(diacritics[latin]),'iu');
275
121
  if( diacritic.match(patt) ){
276
122
  continue;
277
123
  }
278
-
124
+
279
125
  diacritics[latin].push(diacritic);
280
126
  }
281
127
  });
282
-
283
- var latin_chars = Object.keys(diacritics);
284
-
285
-
128
+
129
+ // filter out if there's only one character in the list
130
+ let latin_chars = Object.keys(diacritics);
131
+ for( let i = 0; i < latin_chars.length; i++){
132
+ const latin = latin_chars[i];
133
+ if( diacritics[latin].length < 2 ){
134
+ delete diacritics[latin];
135
+ }
136
+ }
137
+
138
+
286
139
  // latin character pattern
287
140
  // match longer substrings first
288
- latin_chars = latin_chars.sort((a, b) => b.length - a.length );
289
- latin_pat = new RegExp('('+ arrayToPattern(latin_chars) + accent_pat + '*)','g');
290
-
291
-
141
+ latin_chars = Object.keys(diacritics).sort((a, b) => b.length - a.length );
142
+ latin_pat = new RegExp('('+ escapeToPattern(latin_chars) + accent_pat + '*)','gu');
143
+
144
+
292
145
  // build diacritic patterns
293
- // ae needs:
146
+ // ae needs:
294
147
  // (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
295
148
  var diacritic_patterns:TDiacraticList = {};
296
149
  latin_chars.sort((a,b) => a.length -b.length).forEach((latin)=>{
297
-
150
+
298
151
  var substrings = allSubstrings(latin);
299
152
  var pattern = substrings.map((sub_pat)=>{
300
-
153
+
301
154
  sub_pat = sub_pat.map((l)=>{
302
155
  if( diacritics.hasOwnProperty(l) ){
303
- return arrayToPattern(diacritics[l]);
156
+ return escapeToPattern(diacritics[l]);
304
157
  }
305
158
  return l;
306
159
  });
307
-
160
+
308
161
  return arrayToPattern(sub_pat,'');
309
162
  });
310
-
311
- diacritic_patterns[latin] = arrayToPattern(pattern);
163
+
164
+ diacritic_patterns[latin] = arrayToPattern(pattern);
312
165
  });
313
-
166
+
167
+
314
168
  return diacritic_patterns;
315
169
  }
316
170
 
@@ -322,30 +176,24 @@ export const generateDiacritics = ():TDiacraticList => {
322
176
  export const diacriticRegexPoints = (regex:string):string => {
323
177
 
324
178
  if( diacritic_patterns === undefined ){
325
- diacritic_patterns = generateDiacritics();
179
+ diacritic_patterns = generateDiacritics(code_points);
326
180
  }
327
-
181
+
328
182
  const decomposed = regex.normalize('NFKD').toLowerCase();
329
-
183
+
330
184
  return decomposed.split(latin_pat).map((part:string)=>{
331
-
332
- if( part == '' ){
185
+
186
+ // "ffl" or "ffl"
187
+ const no_accent = asciifold(part);
188
+ if( no_accent == '' ){
333
189
  return '';
334
190
  }
335
-
336
- // "ffl" or "ffl"
337
- const no_accent = asciifold(part);
191
+
338
192
  if( diacritic_patterns.hasOwnProperty(no_accent) ){
339
193
  return diacritic_patterns[no_accent];
340
194
  }
341
-
342
- // 'أهلا' (\u{623}\u{647}\u{644}\u{627}) or 'أهلا' (\u{627}\u{654}\u{647}\u{644}\u{627})
343
- const composed_part = part.normalize('NFC');
344
- if( composed_part != part ){
345
- return arrayToPattern([part,composed_part]);
346
- }
347
-
195
+
348
196
  return part;
349
197
  }).join('');
350
-
198
+
351
199
  }
package/lib/sifter.ts CHANGED
@@ -65,9 +65,10 @@ export default class Sifter{
65
65
  }
66
66
 
67
67
  if( word.length > 0 ){
68
- regex = escape_regex(word);
69
68
  if( this.settings.diacritics ){
70
- regex = diacriticRegexPoints(regex);
69
+ regex = diacriticRegexPoints(word);
70
+ }else{
71
+ regex = escape_regex(word);
71
72
  }
72
73
  if( respect_word_boundaries ) regex = "\\b"+regex;
73
74
  }
@@ -204,6 +205,10 @@ export default class Sifter{
204
205
  multipliers:number[] = [];
205
206
 
206
207
 
208
+ if( typeof sort == 'function' ){
209
+ return sort.bind(this);
210
+ }
211
+
207
212
  /**
208
213
  * Fetches the specified sort field value
209
214
  * from a search result item.
@@ -284,7 +289,7 @@ export default class Sifter{
284
289
  * with results.
285
290
  *
286
291
  */
287
- prepareSearch(query:string, optsUser:T.Options):T.PrepareObj {
292
+ prepareSearch(query:string, optsUser:Partial<T.Options>):T.PrepareObj {
288
293
  const weights:T.Weights = {};
289
294
  var options = Object.assign({},optsUser);
290
295
 
@@ -340,7 +345,7 @@ export default class Sifter{
340
345
  }
341
346
  });
342
347
  } else {
343
- iterate(self.items, (item:T.ResultItem, id:string|number) => {
348
+ iterate(self.items, (_:T.ResultItem, id:string|number) => {
344
349
  search.items.push({'score': 1, 'id': id});
345
350
  });
346
351
  }
package/lib/types.ts CHANGED
@@ -1,3 +1,5 @@
1
+ // @ts-ignore TS2691 "An import path cannot end with a '.ts' extension"
2
+ import Sifter from 'sifter.ts';
1
3
 
2
4
  export type Field = {
3
5
  field: string,
@@ -9,16 +11,18 @@ export type Sort = {
9
11
  direction?: string,
10
12
  }
11
13
 
14
+ export type SortFn = (this:Sifter, a:ResultItem, b:ResultItem)=>number;
15
+
12
16
  export type Options = {
13
17
  fields: Field[],
14
- sort: Sort[],
15
- score?: ()=>any,
16
- filter?: boolean,
17
- limit?: number,
18
- sort_empty?: Sort[],
19
- nesting?: boolean,
20
- respect_word_boundaries?: boolean,
21
- conjunction?: string,
18
+ score: ()=>any,
19
+ filter: boolean,
20
+ limit: number,
21
+ sort: SortFn|Sort[],
22
+ sort_empty: SortFn|Sort[],
23
+ nesting: boolean,
24
+ respect_word_boundaries: boolean,
25
+ conjunction: string,
22
26
  }
23
27
 
24
28
  export type Token = {
package/lib/utils.ts CHANGED
@@ -54,7 +54,7 @@ export const scoreValue = (value:string, token:T.Token, weight:number ):number =
54
54
  *
55
55
  * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
56
56
  */
57
- export const escape_regex = (str:string):string => {
57
+ export const escape_regex = (str:string):string => {
58
58
  return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
59
59
  };
60
60
 
@@ -65,6 +65,9 @@ export const escape_regex = (str:string):string => {
65
65
  */
66
66
  export const propToArray = (obj:{[key:string]:any}, key:string) => {
67
67
  var value = obj[key];
68
+
69
+ if( typeof value == 'function' ) return value;
70
+
68
71
  if( value && !Array.isArray(value) ){
69
72
  obj[key] = [value];
70
73
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "autocomplete"
12
12
  ],
13
13
  "description": "A library for textually searching arrays and hashes of objects by property (or multiple properties). Designed specifically for autocomplete.",
14
- "version": "0.8.2",
14
+ "version": "0.9.2",
15
15
  "license": "Apache-2.0",
16
16
  "author": "Brian Reavis <brian@thirdroute.com>",
17
17
  "main": "dist/umd/sifter.js",
@@ -25,11 +25,11 @@
25
25
  "scripts": {
26
26
  "test": "jest --coverage",
27
27
  "test:typescript": "tsc -p .config --noemit",
28
+ "test:coveralls": "npm run build && jest --coverage && cat ./coverage/lcov.info | coveralls",
28
29
  "pretest": "npm run build",
29
- "benchmark": "node --expose-gc benchmark/index.js",
30
+ "benchmark": "npm run build && node --expose-gc benchmark/index.js",
30
31
  "build": "npx rollup -c .config/rollup.config.js",
31
- "build:types": "tsc -p .config --emitDeclarationOnly",
32
- "coveralls": "jest --coverage && cat ./coverage/lcov.info | coveralls"
32
+ "build:types": "tsc -p .config --emitDeclarationOnly"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@babel/core": "^7.13.16",
@@ -39,7 +39,7 @@
39
39
  "@rollup/plugin-babel": "^5.3.0",
40
40
  "coveralls": "^3.1.0",
41
41
  "humanize": "0.0.9",
42
- "jest": "^27.0.5",
42
+ "jest": "^28.1.2",
43
43
  "rollup": "^2.45.2",
44
44
  "rollup-plugin-terser": "^7.0.2",
45
45
  "typescript": "^4.2.4"
@@ -59,5 +59,10 @@
59
59
  "testMatch": [
60
60
  "**/test/**/*.js"
61
61
  ]
62
- }
62
+ },
63
+ "files": [
64
+ "/dist",
65
+ "/lib"
66
+ ],
67
+ "dependencies": {}
63
68
  }
@@ -1,17 +0,0 @@
1
- {
2
- "presets":
3
- [
4
- [
5
- "@babel/preset-env",
6
- {
7
- loose: true,
8
- bugfixes: true,
9
- modules: false
10
- }
11
- ],
12
- "@babel/typescript"
13
- ],
14
- "plugins": [
15
- ["@babel/plugin-proposal-class-properties", { "loose": true }]
16
- ]
17
- }
@@ -1,95 +0,0 @@
1
- import babel from '@rollup/plugin-babel';
2
- import { terser } from 'rollup-plugin-terser';
3
- import pkg from '../package.json';
4
- import path from 'path';
5
- import fs from 'fs';
6
-
7
- var configs = [];
8
- const banner = `/*! sifter.js | https://github.com/orchidjs/sifter.js | Apache License (v2) */`;
9
-
10
- const extensions = [
11
- '.js', '.jsx', '.ts', '.tsx',
12
- ];
13
-
14
- var babel_config = babel({
15
- extensions: extensions,
16
- babelHelpers: 'bundled',
17
- configFile: path.resolve(__dirname,'babel.config.json'),
18
- });
19
-
20
- var terser_config = terser({
21
- mangle: true,
22
- format: {
23
- semicolons: false,
24
- comments: function (node, comment) {
25
- var text = comment.value;
26
- var type = comment.type;
27
- if (type == "comment2") {
28
- // multiline comment
29
- return /\* sifter.js/i.test(text);
30
- }
31
- },
32
- },
33
- });
34
-
35
-
36
- // esm
37
- configs.push({
38
- input: path.resolve(__dirname,'../lib/sifter.ts'),
39
- output:{
40
- dir: path.resolve(__dirname,'../build/esm'),
41
- format: 'esm',
42
- preserveModules: true,
43
- sourcemap: true,
44
- banner: banner,
45
- },
46
- plugins:[babel_config] // resolve_config
47
- });
48
-
49
- // cjs
50
- configs.push({
51
- input: path.resolve(__dirname,'../lib/sifter.ts'),
52
- output:{
53
- dir: path.resolve(__dirname,'../build/cjs'),
54
- format: 'cjs',
55
- preserveModules: true,
56
- sourcemap: true,
57
- banner: banner,
58
- },
59
- plugins:[babel_config] //resolve_config
60
- });
61
-
62
-
63
- // umd
64
- configs.push({
65
- input: path.resolve(__dirname,'../lib/sifter.ts'),
66
- output: {
67
- name: 'sifter',
68
- file: `build/umd/sifter.js`,
69
- format: 'umd',
70
- sourcemap: true,
71
- banner: banner
72
- },
73
- plugins:[
74
- babel_config,
75
- ]
76
- });
77
-
78
- // umd min
79
- configs.push({
80
- input: path.resolve(__dirname,'../lib/sifter.ts'),
81
- output: {
82
- name: 'sifter',
83
- file: `build/umd/sifter.min.js`,
84
- format: 'umd',
85
- sourcemap: true,
86
- banner: banner
87
- },
88
- plugins:[
89
- babel_config,
90
- terser_config
91
- ]
92
- });
93
-
94
-
95
- export default configs;
@@ -1,16 +0,0 @@
1
- {
2
- "include": ["../lib/**/*"],
3
- "compilerOptions": {
4
- "allowJs": true,
5
- "checkJs": true,
6
- "strict": true,
7
- "target": "esnext",
8
- "module": "esnext",
9
- "noUnusedLocals": true,
10
-
11
- "declaration": true,
12
- "declarationDir": "../dist/types",
13
- "isolatedModules": true,
14
- "moduleResolution": "node"
15
- },
16
- }
package/.travis.yml DELETED
@@ -1,9 +0,0 @@
1
- sudo: false
2
- language: node_js
3
- node_js:
4
- - "10"
5
- - "12"
6
- - "14"
7
- script:
8
- - npm test
9
- - npm run coveralls
package/Makefile DELETED
@@ -1,27 +0,0 @@
1
- .PHONY: compile release benchmark
2
-
3
- all: compile
4
-
5
- benchmark:
6
- node --expose-gc benchmark/index.js
7
-
8
- compile:
9
- npm run build
10
-
11
- release:
12
- ifeq ($(strip $(version)),)
13
- @echo "\033[31mERROR:\033[0;39m No version provided."
14
- @echo "\033[1;30mmake release version=1.0.0\033[0;39m"
15
- else
16
- sed -i.bak 's/"version": "[^"]*"/"version": "$(version)"/' package.json
17
- sed -i.bak 's/"version": "[^"]*"/"version": "$(version)"/' bower.json
18
- rm *.bak
19
- make compile
20
- git add .
21
- git commit -a -m "Released $(version)."
22
- git tag v$(version)
23
- git push origin master
24
- git push origin --tags
25
- npm publish
26
- @echo "\033[32mv${version} released\033[0;39m"
27
- endif