@orchidjs/sifter 0.8.1 → 0.9.1

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 +25 -3
  2. package/dist/cjs/diacritics.js +19 -3
  3. package/dist/cjs/diacritics.js.map +1 -1
  4. package/dist/cjs/sifter.js +6 -1
  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 +19 -3
  9. package/dist/esm/diacritics.js.map +1 -1
  10. package/dist/esm/sifter.js +6 -1
  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 +1 -0
  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 +26 -4
  19. package/dist/umd/sifter.js.map +1 -1
  20. package/dist/umd/sifter.min.js +11 -4
  21. package/dist/umd/sifter.min.js.map +1 -1
  22. package/lib/diacritics.ts +22 -6
  23. package/lib/sifter.ts +6 -2
  24. package/lib/types.ts +12 -8
  25. package/lib/utils.ts +3 -0
  26. package/package.json +6 -2
  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 -157
  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 -148
  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 -618
  45. package/build/umd/sifter.js.map +0 -1
  46. package/build/umd/sifter.min.js +0 -77
  47. package/build/umd/sifter.min.js.map +0 -1
  48. package/coverage/clover.xml +0 -251
  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 -1085
  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 -419
  61. package/coverage/lcov.info +0 -492
  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 -129
@@ -1,492 +0,0 @@
1
- TN:
2
- SF:lib/diacritics.ts
3
- FN:156,(anonymous_0)
4
- FN:161,(anonymous_1)
5
- FN:212,(anonymous_2)
6
- FN:224,(anonymous_3)
7
- FN:229,(anonymous_4)
8
- FN:246,(anonymous_5)
9
- FN:249,(anonymous_6)
10
- FN:272,(anonymous_7)
11
- FN:280,(anonymous_8)
12
- FN:280,(anonymous_9)
13
- FN:283,(anonymous_10)
14
- FN:285,(anonymous_11)
15
- FN:306,(anonymous_12)
16
- FN:314,(anonymous_13)
17
- FNF:14
18
- FNH:14
19
- FNDA:9943,(anonymous_0)
20
- FNDA:122,(anonymous_1)
21
- FNDA:988,(anonymous_2)
22
- FNDA:312,(anonymous_3)
23
- FNDA:90,(anonymous_4)
24
- FNDA:6,(anonymous_5)
25
- FNDA:138,(anonymous_6)
26
- FNDA:876,(anonymous_7)
27
- FNDA:924,(anonymous_8)
28
- FNDA:234,(anonymous_9)
29
- FNDA:324,(anonymous_10)
30
- FNDA:426,(anonymous_11)
31
- FNDA:3915,(anonymous_12)
32
- FNDA:9199,(anonymous_13)
33
- DA:7,7
34
- DA:8,7
35
- DA:11,7
36
- DA:17,7
37
- DA:125,7
38
- DA:156,7
39
- DA:157,9943
40
- DA:162,122
41
- DA:212,7
42
- DA:213,988
43
- DA:214,586
44
- DA:216,402
45
- DA:224,7
46
- DA:226,312
47
- DA:228,78
48
- DA:229,78
49
- DA:230,90
50
- DA:231,90
51
- DA:232,90
52
- DA:234,90
53
- DA:235,90
54
- DA:236,90
55
- DA:239,78
56
- DA:246,7
57
- DA:248,6
58
- DA:249,6
59
- DA:251,138
60
- DA:253,5808
61
- DA:254,5808
62
- DA:256,5808
63
- DA:257,2004
64
- DA:260,3804
65
- DA:261,234
66
- DA:263,3804
67
- DA:267,6
68
- DA:272,876
69
- DA:273,6
70
- DA:279,6
71
- DA:280,924
72
- DA:282,234
73
- DA:283,234
74
- DA:285,324
75
- DA:286,426
76
- DA:287,420
77
- DA:289,6
78
- DA:292,324
79
- DA:295,234
80
- DA:298,6
81
- DA:306,7
82
- DA:308,3915
83
- DA:309,6
84
- DA:312,3915
85
- DA:314,3915
86
- DA:316,9199
87
- DA:317,5172
88
- DA:321,4027
89
- DA:322,4027
90
- DA:323,2690
91
- DA:327,1337
92
- DA:328,1337
93
- DA:329,4
94
- DA:332,1333
95
- LF:62
96
- LH:62
97
- BRDA:212,0,0,664
98
- BRDA:213,1,0,586
99
- BRDA:213,1,1,402
100
- BRDA:226,2,0,234
101
- BRDA:226,2,1,78
102
- BRDA:256,3,0,2004
103
- BRDA:256,3,1,3804
104
- BRDA:260,4,0,234
105
- BRDA:260,4,1,3570
106
- BRDA:286,5,0,420
107
- BRDA:286,5,1,6
108
- BRDA:308,6,0,6
109
- BRDA:308,6,1,3909
110
- BRDA:316,7,0,5172
111
- BRDA:316,7,1,4027
112
- BRDA:322,8,0,2690
113
- BRDA:322,8,1,1337
114
- BRDA:328,9,0,4
115
- BRDA:328,9,1,1333
116
- BRF:19
117
- BRH:19
118
- end_of_record
119
- TN:
120
- SF:lib/sifter.ts
121
- FN:35,(anonymous_0)
122
- FN:45,(anonymous_1)
123
- FN:56,(anonymous_2)
124
- FN:94,(anonymous_3)
125
- FN:99,(anonymous_4)
126
- FN:104,(anonymous_5)
127
- FN:113,(anonymous_6)
128
- FN:122,(anonymous_7)
129
- FN:126,(anonymous_8)
130
- FN:132,(anonymous_9)
131
- FN:149,(anonymous_10)
132
- FN:159,(anonymous_11)
133
- FN:165,(anonymous_12)
134
- FN:175,(anonymous_13)
135
- FN:177,(anonymous_14)
136
- FN:192,(anonymous_15)
137
- FN:197,(anonymous_16)
138
- FN:212,get_field
139
- FN:259,(anonymous_18)
140
- FN:266,(anonymous_19)
141
- FN:287,(anonymous_20)
142
- FN:298,(anonymous_21)
143
- FN:324,(anonymous_22)
144
- FN:336,(anonymous_23)
145
- FN:343,(anonymous_24)
146
- FNF:25
147
- FNH:23
148
- FNDA:36,(anonymous_0)
149
- FNDA:3916,(anonymous_1)
150
- FNDA:3916,(anonymous_2)
151
- FNDA:3,(anonymous_3)
152
- FNDA:38,(anonymous_4)
153
- FNDA:0,(anonymous_5)
154
- FNDA:2,(anonymous_6)
155
- FNDA:28,(anonymous_7)
156
- FNDA:41,(anonymous_8)
157
- FNDA:62,(anonymous_9)
158
- FNDA:137,(anonymous_10)
159
- FNDA:58,(anonymous_11)
160
- FNDA:7,(anonymous_12)
161
- FNDA:17,(anonymous_13)
162
- FNDA:34,(anonymous_14)
163
- FNDA:0,(anonymous_15)
164
- FNDA:34,(anonymous_16)
165
- FNDA:152,get_field
166
- FNDA:38,(anonymous_18)
167
- FNDA:27,(anonymous_19)
168
- FNDA:40,(anonymous_20)
169
- FNDA:59,(anonymous_21)
170
- FNDA:34,(anonymous_22)
171
- FNDA:68,(anonymous_23)
172
- FNDA:31,(anonymous_24)
173
- DA:35,72
174
- DA:36,36
175
- DA:37,36
176
- DA:46,3916
177
- DA:48,3906
178
- DA:49,3906
179
- DA:52,3906
180
- DA:53,31
181
- DA:56,3906
182
- DA:58,3916
183
- DA:59,3916
184
- DA:62,3916
185
- DA:63,3
186
- DA:64,3
187
- DA:67,3916
188
- DA:68,3915
189
- DA:69,3915
190
- DA:70,3915
191
- DA:72,3915
192
- DA:75,3916
193
- DA:82,3906
194
- DA:95,3
195
- DA:96,3
196
- DA:100,38
197
- DA:101,38
198
- DA:103,38
199
- DA:104,9
200
- DA:107,29
201
- DA:108,29
202
- DA:109,29
203
- DA:110,29
204
- DA:112,29
205
- DA:113,2
206
- DA:122,28
207
- DA:125,28
208
- DA:126,15
209
- DA:127,41
210
- DA:128,41
211
- DA:132,13
212
- DA:133,62
213
- DA:136,62
214
- DA:138,6
215
- DA:140,6
216
- DA:141,1
217
- DA:143,5
218
- DA:149,56
219
- DA:150,137
220
- DA:154,62
221
- DA:158,28
222
- DA:159,22
223
- DA:160,58
224
- DA:164,6
225
- DA:165,2
226
- DA:166,7
227
- DA:167,7
228
- DA:168,11
229
- DA:169,11
230
- DA:170,5
231
- DA:172,1
232
- DA:175,4
233
- DA:176,17
234
- DA:177,17
235
- DA:178,34
236
- DA:180,17
237
- DA:193,0
238
- DA:194,0
239
- DA:200,34
240
- DA:201,34
241
- DA:202,34
242
- DA:203,34
243
- DA:204,34
244
- DA:212,34
245
- DA:213,152
246
- DA:214,128
247
- DA:218,34
248
- DA:219,13
249
- DA:220,17
250
- DA:221,17
251
- DA:228,34
252
- DA:229,25
253
- DA:230,25
254
- DA:231,6
255
- DA:232,2
256
- DA:233,2
257
- DA:236,25
258
- DA:237,23
259
- DA:240,9
260
- DA:241,11
261
- DA:242,0
262
- DA:243,0
263
- DA:248,34
264
- DA:249,40
265
- DA:253,34
266
- DA:254,34
267
- DA:255,0
268
- DA:256,34
269
- DA:257,28
270
- DA:258,28
271
- DA:259,28
272
- DA:260,38
273
- DA:266,6
274
- DA:268,27
275
- DA:269,38
276
- DA:270,38
277
- DA:274,38
278
- DA:276,5
279
- DA:288,40
280
- DA:289,40
281
- DA:291,40
282
- DA:292,40
283
- DA:295,40
284
- DA:296,39
285
- DA:297,39
286
- DA:298,39
287
- DA:299,59
288
- DA:300,51
289
- DA:302,59
290
- DA:303,59
291
- DA:305,39
292
- DA:309,40
293
- DA:325,34
294
- DA:327,34
295
- DA:328,34
296
- DA:329,34
297
- DA:332,34
298
- DA:335,34
299
- DA:336,25
300
- DA:337,68
301
- DA:338,68
302
- DA:339,40
303
- DA:343,9
304
- DA:344,31
305
- DA:348,34
306
- DA:349,34
307
- DA:352,34
308
- DA:353,34
309
- DA:354,3
310
- DA:357,34
311
- LF:138
312
- LH:133
313
- BRDA:37,0,0,36
314
- BRDA:37,0,1,36
315
- BRDA:46,1,0,10
316
- BRDA:46,1,1,3906
317
- BRDA:46,2,0,3916
318
- BRDA:46,2,1,3906
319
- BRDA:52,3,0,31
320
- BRDA:52,3,1,3875
321
- BRDA:62,4,0,3
322
- BRDA:62,4,1,3913
323
- BRDA:62,5,0,3916
324
- BRDA:62,5,1,38
325
- BRDA:67,6,0,3915
326
- BRDA:67,6,1,1
327
- BRDA:69,7,0,3915
328
- BRDA:69,7,1,0
329
- BRDA:72,8,0,6
330
- BRDA:72,8,1,3909
331
- BRDA:77,9,0,3915
332
- BRDA:77,9,1,1
333
- BRDA:103,10,0,9
334
- BRDA:103,10,1,29
335
- BRDA:112,11,0,1
336
- BRDA:112,11,1,28
337
- BRDA:125,12,0,15
338
- BRDA:125,12,1,13
339
- BRDA:136,13,0,6
340
- BRDA:136,13,1,56
341
- BRDA:140,14,0,1
342
- BRDA:140,14,1,5
343
- BRDA:140,15,0,6
344
- BRDA:140,15,1,2
345
- BRDA:158,16,0,22
346
- BRDA:158,16,1,6
347
- BRDA:164,17,0,2
348
- BRDA:164,17,1,4
349
- BRDA:169,18,0,6
350
- BRDA:169,18,1,5
351
- BRDA:202,19,0,1
352
- BRDA:202,19,1,33
353
- BRDA:202,20,0,34
354
- BRDA:202,20,1,9
355
- BRDA:213,21,0,24
356
- BRDA:213,21,1,128
357
- BRDA:218,22,0,13
358
- BRDA:218,22,1,21
359
- BRDA:220,23,0,17
360
- BRDA:220,23,1,0
361
- BRDA:220,24,0,17
362
- BRDA:220,24,1,11
363
- BRDA:228,25,0,25
364
- BRDA:228,25,1,9
365
- BRDA:231,26,0,2
366
- BRDA:231,26,1,4
367
- BRDA:236,27,0,23
368
- BRDA:236,27,1,2
369
- BRDA:241,28,0,0
370
- BRDA:241,28,1,11
371
- BRDA:249,29,0,25
372
- BRDA:249,29,1,15
373
- BRDA:254,30,0,0
374
- BRDA:254,30,1,34
375
- BRDA:256,31,0,28
376
- BRDA:256,31,1,6
377
- BRDA:274,32,0,22
378
- BRDA:274,32,1,16
379
- BRDA:295,33,0,39
380
- BRDA:295,33,1,1
381
- BRDA:299,34,0,51
382
- BRDA:299,34,1,8
383
- BRDA:303,35,0,57
384
- BRDA:303,35,1,2
385
- BRDA:316,36,0,2
386
- BRDA:316,36,1,38
387
- BRDA:332,37,0,34
388
- BRDA:332,37,1,34
389
- BRDA:335,38,0,25
390
- BRDA:335,38,1,9
391
- BRDA:338,39,0,40
392
- BRDA:338,39,1,28
393
- BRDA:338,40,0,68
394
- BRDA:338,40,1,65
395
- BRDA:349,41,0,34
396
- BRDA:349,41,1,0
397
- BRDA:353,42,0,3
398
- BRDA:353,42,1,31
399
- BRF:86
400
- BRH:81
401
- end_of_record
402
- TN:
403
- SF:lib/utils.ts
404
- FN:15,(anonymous_0)
405
- FN:26,(anonymous_1)
406
- FN:38,(anonymous_2)
407
- FN:57,(anonymous_3)
408
- FN:69,(anonymous_4)
409
- FN:87,(anonymous_5)
410
- FN:104,(anonymous_6)
411
- FNF:7
412
- FNH:7
413
- FNDA:302,(anonymous_0)
414
- FNDA:12,(anonymous_1)
415
- FNDA:184,(anonymous_2)
416
- FNDA:3963,(anonymous_3)
417
- FNDA:119,(anonymous_4)
418
- FNDA:107,(anonymous_5)
419
- FNDA:77,(anonymous_6)
420
- DA:15,7
421
- DA:16,302
422
- DA:17,301
423
- DA:26,7
424
- DA:27,12
425
- DA:28,11
426
- DA:29,11
427
- DA:30,11
428
- DA:38,7
429
- DA:41,184
430
- DA:43,168
431
- DA:44,168
432
- DA:45,168
433
- DA:47,58
434
- DA:48,58
435
- DA:50,58
436
- DA:57,7
437
- DA:59,3963
438
- DA:69,7
439
- DA:70,119
440
- DA:71,119
441
- DA:72,23
442
- DA:87,7
443
- DA:89,107
444
- DA:90,50
445
- DA:94,57
446
- DA:95,139
447
- DA:96,139
448
- DA:104,7
449
- DA:105,77
450
- DA:106,23
451
- DA:108,54
452
- DA:109,54
453
- DA:110,54
454
- DA:111,39
455
- DA:112,12
456
- LF:36
457
- LH:36
458
- BRDA:16,0,0,1
459
- BRDA:16,0,1,301
460
- BRDA:27,1,0,1
461
- BRDA:27,1,1,11
462
- BRDA:29,2,0,33
463
- BRDA:29,2,1,22
464
- BRDA:41,3,0,16
465
- BRDA:41,3,1,168
466
- BRDA:45,4,0,110
467
- BRDA:45,4,1,58
468
- BRDA:48,5,0,44
469
- BRDA:48,5,1,14
470
- BRDA:71,6,0,23
471
- BRDA:71,6,1,96
472
- BRDA:71,7,0,119
473
- BRDA:71,7,1,55
474
- BRDA:89,8,0,50
475
- BRDA:89,8,1,57
476
- BRDA:95,9,0,139
477
- BRDA:95,9,1,0
478
- BRDA:105,10,0,23
479
- BRDA:105,10,1,54
480
- BRDA:105,11,0,77
481
- BRDA:105,11,1,23
482
- BRDA:106,12,0,8
483
- BRDA:106,12,1,15
484
- BRDA:106,13,0,6
485
- BRDA:106,13,1,9
486
- BRDA:110,14,0,15
487
- BRDA:110,14,1,39
488
- BRDA:111,15,0,27
489
- BRDA:111,15,1,12
490
- BRF:32
491
- BRH:31
492
- end_of_record
package/release.sh DELETED
@@ -1,119 +0,0 @@
1
- #!/bin/bash
2
-
3
- VERSION=$1
4
-
5
- # This is a general-purpose function to ask Yes/No questions in Bash, either
6
- # with or without a default answer. It keeps repeating the question until it
7
- # gets a valid answer.
8
- # https://gist.github.com/davejamesmiller/1965569
9
- ask() {
10
- local prompt default reply
11
-
12
- if [ "${2:-}" = "Y" ]; then
13
- prompt="Y/n"
14
- default=Y
15
- elif [ "${2:-}" = "N" ]; then
16
- prompt="y/N"
17
- default=N
18
- else
19
- prompt="y/n"
20
- default=
21
- fi
22
-
23
- while true; do
24
-
25
- # Ask the question (not using "read -p" as it uses stderr not stdout)
26
- echo -n "$1 [$prompt] "
27
-
28
- # Read the answer (use /dev/tty in case stdin is redirected from somewhere else)
29
- read reply </dev/tty
30
-
31
- # Default?
32
- if [ -z "$reply" ]; then
33
- reply=$default
34
- fi
35
-
36
- # Check if the reply is valid
37
- case "$reply" in
38
- Y*|y*) return 0 ;;
39
- N*|n*) return 1 ;;
40
- esac
41
-
42
- done
43
- }
44
-
45
- # make sure the release is being made from the master branch
46
- BRANCH="$(git rev-parse --abbrev-ref HEAD)"
47
- if [[ "$BRANCH" != "master" ]]; then
48
- echo 'Not on master branch';
49
- exit 1;
50
- fi
51
-
52
-
53
- # make sure there aren't any uncommited changes
54
- if ! git diff-index --quiet HEAD --; then
55
- echo 'Commit all changes before releas before making release'
56
- exit
57
- fi
58
-
59
-
60
- # make sure release number is valid
61
- if ! [[ "$VERSION" =~ ^([0-9]\.[0-9]\.[0-9]) ]]; then
62
- echo "Release number must match a semver pattern similar to 1.0.0"
63
- exit
64
- fi
65
-
66
-
67
- # make sure tests pass
68
- if ! npm test; then
69
- echo 'Tests failed... cannot create release'
70
- exit
71
- fi
72
-
73
- # update package.json and package-lock.json
74
- if ! sed -i 's/"version": "[^"]*"/"version": "'$VERSION'"/' package.json; then
75
- echo 'version not replaced in package-lock.json'
76
- exit
77
- fi
78
-
79
- # build from source
80
- if ! npm run build; then
81
- echo 'Build failed... cannot create release'
82
- exit
83
- fi
84
-
85
- # remove contents of dist folder
86
- if ! rm -r dist/*; then
87
- echo '/dist not emptied... cannot create release'
88
- exit
89
- fi
90
-
91
-
92
- # copy /build to /dist
93
- if ! cp -r build/* dist; then
94
- echo '/build not copied to /dist... cannot create release'
95
- exit
96
- fi
97
-
98
-
99
- # make sure types are up-to-date
100
- if ! npm run build:types; then
101
- echo 'types not generated'
102
- exit
103
- fi
104
-
105
-
106
- # prompt before finalizing
107
- if ! ask "Version $VERSION is ready for release. Are you sure?"; then
108
- echo 'release aborted'
109
- exit
110
- fi
111
-
112
-
113
- git add .
114
- git commit -a -m "v$VERSION Release"
115
- git tag "v$VERSION"
116
- git push origin master
117
- git push origin --tags
118
- npm publish
119
- echo "\033[32mv${VERSION} released\033[0;39m"
@@ -1,64 +0,0 @@
1
- var assert = require('assert');
2
- var diacritics = require('../build/cjs/diacritics.js');
3
- var utils = require('../build/cjs/utils.js');
4
- var Sifter = require('../build/cjs/sifter.js');
5
-
6
- describe('diacritics', () => {
7
-
8
- it('Should match composed and decomposed strings', () => {
9
-
10
- const sifter = new Sifter([]);
11
- const composed = 'أهلا'; // '\u{623}\u{647}\u{644}\u{627}'
12
- const decomposed = 'أهلا'; // '\u{627}\u{654}\u{647}\u{644}\u{627}'
13
-
14
- assert.notEqual(composed,decomposed);
15
-
16
-
17
- tokens = sifter.tokenize(composed);
18
- assert.equal(tokens[0].regex.test(composed), true);
19
-
20
- tokens = sifter.tokenize(decomposed);
21
- assert.equal(tokens[0].regex.test(decomposed), true);
22
-
23
- tokens = sifter.tokenize(composed);
24
- assert.equal(tokens[0].regex.test(decomposed), true);
25
-
26
- tokens = sifter.tokenize(decomposed);
27
- assert.equal(tokens[0].regex.test(composed), true);
28
-
29
- });
30
-
31
-
32
- it('Should match all diacritic code points',()=>{
33
-
34
- const sifter = new Sifter([]);
35
-
36
- diacritics.code_points.forEach((code_range)=>{
37
- for(let i = code_range[0]; i <= code_range[1]; i++){
38
-
39
- let composed = String.fromCharCode(i);
40
- let decomposed = composed.normalize('NFKD');
41
-
42
- if( composed.trim().length == 0 ){
43
- continue;
44
- }
45
-
46
- tokens = sifter.tokenize(composed);
47
- assert.equal(tokens[0].regex.test(composed), true, 'composed should match composed for ' + composed + ' regex: '+tokens[0].regex);
48
-
49
- tokens = sifter.tokenize(decomposed);
50
- assert.equal(tokens[0].regex.test(decomposed), true, 'decomposed should match composed for ' + decomposed + ' and ' + composed + ' regex: '+tokens[0].regex);
51
-
52
- tokens = sifter.tokenize(composed);
53
- assert.equal(tokens[0].regex.test(decomposed), true, 'composed should match decomposed for ' + composed + ' and ' + decomposed + ' regex: '+tokens[0].regex);
54
-
55
- tokens = sifter.tokenize(decomposed);
56
- assert.equal(tokens[0].regex.test(composed), true, 'decomposed should match composed for ' + decomposed + ' and ' + composed + ' regex: '+tokens[0].regex);
57
-
58
- };
59
- });
60
-
61
- });
62
-
63
-
64
- });
@@ -1,55 +0,0 @@
1
- var assert = require('assert');
2
- var Sifter = require('../build/cjs/sifter.js');
3
-
4
- describe('#getScoreFunction()', function() {
5
-
6
- it('should acknowledge AND "conjunction" option', function() {
7
- var score, search, sifter = new Sifter([]);
8
-
9
- score = sifter.getScoreFunction('one two', {fields: ['a','b'], conjunction: 'and'});
10
- assert.equal(score({a: 'one'}) > 0, false);
11
- assert.equal(score({a: 'one', b: 'two'}) > 0, true);
12
- assert.equal(score({a: 'one', b: 'one'}) > 0, false);
13
- assert.equal(score({a: 'one', b: 'three'}) > 0, false);
14
- assert.equal(score({a: 'three', b: 'three'}) > 0, false);
15
- });
16
-
17
- it('should acknowledge OR "conjunction" option', function() {
18
- var score, search, sifter = new Sifter([]);
19
-
20
- score = sifter.getScoreFunction('one two', {fields: ['a','b'], conjunction: 'or'});
21
- assert.equal(score({a: 'one'}) > 0, true);
22
- assert.equal(score({a: 'one', b: 'two'}) > 0, true);
23
- assert.equal(score({a: 'one', b: 'one'}) > 0, true);
24
- assert.equal(score({a: 'one', b: 'three'}) > 0, true);
25
- assert.equal(score({a: 'three', b: 'three'}) > 0, false);
26
- });
27
-
28
- describe('with query and options', function() {
29
-
30
- it('should return a function that returns a number', function() {
31
- var score, search, sifter = new Sifter([]);
32
-
33
- score = sifter.getScoreFunction('test', {fields: ['a','b']});
34
- assert.equal(typeof score({a: 'test'}), 'number');
35
- assert.equal(score({a: 'test'}) > 0, true);
36
- assert.equal(typeof score({}), 'number');
37
- });
38
-
39
- });
40
-
41
- describe('with pre-prepared search', function() {
42
-
43
- it('should return a function that returns a number', function() {
44
- var score, search, sifter = new Sifter([]);
45
-
46
- search = sifter.prepareSearch('test', {fields: ['a','b']});
47
- score = sifter._getScoreFunction(search);
48
- assert.equal(typeof score({a: 'test'}), 'number');
49
- assert.equal(score({a: 'test'}) > 0, true);
50
- assert.equal(typeof score({}), 'number');
51
- });
52
-
53
- });
54
-
55
- });