@orchidjs/sifter 0.7.3 → 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.
Files changed (68) hide show
  1. package/README.md +25 -3
  2. package/dist/cjs/diacritics.js +118 -68
  3. package/dist/cjs/diacritics.js.map +1 -1
  4. package/dist/cjs/sifter.js +9 -7
  5. package/dist/cjs/sifter.js.map +1 -1
  6. package/dist/cjs/utils.js +21 -15
  7. package/dist/cjs/utils.js.map +1 -1
  8. package/dist/esm/diacritics.js +116 -69
  9. package/dist/esm/diacritics.js.map +1 -1
  10. package/dist/esm/sifter.js +10 -8
  11. package/dist/esm/sifter.js.map +1 -1
  12. package/dist/esm/utils.js +21 -15
  13. package/dist/esm/utils.js.map +1 -1
  14. package/dist/types/diacritics.d.ts +40 -0
  15. package/dist/types/sifter.d.ts +64 -0
  16. package/dist/types/types.d.ts +45 -0
  17. package/dist/types/utils.d.ts +52 -0
  18. package/dist/umd/sifter.js +144 -89
  19. package/dist/umd/sifter.js.map +1 -1
  20. package/dist/umd/sifter.min.js +56 -35
  21. package/dist/umd/sifter.min.js.map +1 -1
  22. package/lib/diacritics.ts +145 -81
  23. package/lib/sifter.ts +32 -83
  24. package/lib/types.ts +54 -0
  25. package/lib/utils.ts +16 -9
  26. package/package.json +8 -3
  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 -123
  33. package/build/cjs/diacritics.js.map +0 -1
  34. package/build/cjs/sifter.js +0 -375
  35. package/build/cjs/sifter.js.map +0 -1
  36. package/build/cjs/utils.js +0 -108
  37. package/build/cjs/utils.js.map +0 -1
  38. package/build/esm/diacritics.js +0 -117
  39. package/build/esm/diacritics.js.map +0 -1
  40. package/build/esm/sifter.js +0 -373
  41. package/build/esm/sifter.js.map +0 -1
  42. package/build/esm/utils.js +0 -98
  43. package/build/esm/utils.js.map +0 -1
  44. package/build/umd/sifter.js +0 -585
  45. package/build/umd/sifter.js.map +0 -1
  46. package/build/umd/sifter.min.js +0 -63
  47. package/build/umd/sifter.min.js.map +0 -1
  48. package/coverage/clover.xml +0 -207
  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 -929
  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 -1322
  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 -398
  61. package/coverage/lcov.info +0 -419
  62. package/release.sh +0 -112
  63. package/test/getScoreFunction.js +0 -55
  64. package/test/prepareSearch.js +0 -40
  65. package/test/search.js +0 -307
  66. package/test/sorting.js +0 -193
  67. package/test/tokenize.js +0 -63
  68. package/test/utils.js +0 -28
@@ -1,419 +0,0 @@
1
- TN:
2
- SF:lib/diacritics.ts
3
- FN:141,asciifold
4
- FN:187,generateDiacritics
5
- FN:200,(anonymous_2)
6
- FN:235,diacriticRegexPoints
7
- FNF:4
8
- FNH:4
9
- FNDA:146,asciifold
10
- FNDA:5,generateDiacritics
11
- FNDA:115,(anonymous_2)
12
- FNDA:41,diacriticRegexPoints
13
- DA:110,6
14
- DA:142,146
15
- DA:189,5
16
- DA:198,5
17
- DA:200,5
18
- DA:202,115
19
- DA:203,4840
20
- DA:204,4840
21
- DA:206,4840
22
- DA:208,1700
23
- DA:211,3140
24
- DA:213,3140
25
- DA:214,65
26
- DA:217,3140
27
- DA:218,190
28
- DA:220,3140
29
- DA:226,5
30
- DA:234,6
31
- DA:237,41
32
- DA:238,5
33
- DA:241,41
34
- DA:242,1558
35
- DA:243,1558
36
- DA:246,41
37
- LF:24
38
- LH:24
39
- BRDA:206,0,0,1700
40
- BRDA:206,0,1,3140
41
- BRDA:213,1,0,65
42
- BRDA:213,1,1,3075
43
- BRDA:217,2,0,190
44
- BRDA:217,2,1,2950
45
- BRDA:237,3,0,5
46
- BRDA:237,3,1,36
47
- BRDA:242,4,0,1558
48
- BRDA:242,4,1,0
49
- BRF:10
50
- BRH:9
51
- end_of_record
52
- TN:
53
- SF:lib/sifter.ts
54
- FN:86,(anonymous_0)
55
- FN:96,(anonymous_1)
56
- FN:107,(anonymous_2)
57
- FN:145,(anonymous_3)
58
- FN:150,(anonymous_4)
59
- FN:155,(anonymous_5)
60
- FN:164,(anonymous_6)
61
- FN:176,(anonymous_7)
62
- FN:180,(anonymous_8)
63
- FN:186,(anonymous_9)
64
- FN:203,(anonymous_10)
65
- FN:213,(anonymous_11)
66
- FN:219,(anonymous_12)
67
- FN:229,(anonymous_13)
68
- FN:231,(anonymous_14)
69
- FN:246,(anonymous_15)
70
- FN:251,(anonymous_16)
71
- FN:266,get_field
72
- FN:313,(anonymous_18)
73
- FN:320,(anonymous_19)
74
- FN:341,(anonymous_20)
75
- FN:352,(anonymous_21)
76
- FN:379,(anonymous_22)
77
- FN:391,(anonymous_23)
78
- FN:398,(anonymous_24)
79
- FNF:25
80
- FNH:23
81
- FNDA:32,(anonymous_0)
82
- FNDA:42,(anonymous_1)
83
- FNDA:42,(anonymous_2)
84
- FNDA:3,(anonymous_3)
85
- FNDA:36,(anonymous_4)
86
- FNDA:0,(anonymous_5)
87
- FNDA:2,(anonymous_6)
88
- FNDA:26,(anonymous_7)
89
- FNDA:38,(anonymous_8)
90
- FNDA:62,(anonymous_9)
91
- FNDA:137,(anonymous_10)
92
- FNDA:55,(anonymous_11)
93
- FNDA:7,(anonymous_12)
94
- FNDA:17,(anonymous_13)
95
- FNDA:34,(anonymous_14)
96
- FNDA:0,(anonymous_15)
97
- FNDA:32,(anonymous_16)
98
- FNDA:152,get_field
99
- FNDA:38,(anonymous_18)
100
- FNDA:27,(anonymous_19)
101
- FNDA:38,(anonymous_20)
102
- FNDA:57,(anonymous_21)
103
- FNDA:32,(anonymous_22)
104
- FNDA:65,(anonymous_23)
105
- FNDA:31,(anonymous_24)
106
- DA:86,64
107
- DA:87,32
108
- DA:88,32
109
- DA:97,42
110
- DA:99,32
111
- DA:100,32
112
- DA:103,32
113
- DA:104,29
114
- DA:107,32
115
- DA:109,42
116
- DA:110,42
117
- DA:113,42
118
- DA:114,3
119
- DA:115,3
120
- DA:118,42
121
- DA:119,41
122
- DA:120,41
123
- DA:121,41
124
- DA:123,41
125
- DA:126,42
126
- DA:133,32
127
- DA:146,3
128
- DA:147,3
129
- DA:151,36
130
- DA:152,36
131
- DA:154,36
132
- DA:155,9
133
- DA:158,27
134
- DA:159,27
135
- DA:160,27
136
- DA:161,27
137
- DA:163,27
138
- DA:164,2
139
- DA:176,26
140
- DA:179,26
141
- DA:180,13
142
- DA:181,38
143
- DA:182,38
144
- DA:186,13
145
- DA:187,62
146
- DA:190,62
147
- DA:192,6
148
- DA:194,6
149
- DA:195,1
150
- DA:197,5
151
- DA:203,56
152
- DA:204,137
153
- DA:208,62
154
- DA:212,26
155
- DA:213,20
156
- DA:214,55
157
- DA:218,6
158
- DA:219,2
159
- DA:220,7
160
- DA:221,7
161
- DA:222,11
162
- DA:223,11
163
- DA:224,5
164
- DA:226,1
165
- DA:229,4
166
- DA:230,17
167
- DA:231,17
168
- DA:232,34
169
- DA:234,17
170
- DA:247,0
171
- DA:248,0
172
- DA:254,32
173
- DA:255,32
174
- DA:256,32
175
- DA:257,32
176
- DA:258,32
177
- DA:266,32
178
- DA:267,152
179
- DA:268,128
180
- DA:272,32
181
- DA:273,13
182
- DA:274,17
183
- DA:275,17
184
- DA:282,32
185
- DA:283,23
186
- DA:284,23
187
- DA:285,6
188
- DA:286,2
189
- DA:287,2
190
- DA:290,23
191
- DA:291,21
192
- DA:294,9
193
- DA:295,11
194
- DA:296,0
195
- DA:297,0
196
- DA:302,32
197
- DA:303,38
198
- DA:307,32
199
- DA:308,32
200
- DA:309,0
201
- DA:310,32
202
- DA:311,26
203
- DA:312,26
204
- DA:313,26
205
- DA:314,38
206
- DA:320,6
207
- DA:322,27
208
- DA:323,38
209
- DA:324,38
210
- DA:328,38
211
- DA:330,5
212
- DA:342,38
213
- DA:343,38
214
- DA:345,38
215
- DA:346,38
216
- DA:349,38
217
- DA:350,37
218
- DA:351,37
219
- DA:352,37
220
- DA:353,57
221
- DA:354,49
222
- DA:356,57
223
- DA:357,57
224
- DA:359,37
225
- DA:362,38
226
- DA:364,38
227
- DA:380,32
228
- DA:382,32
229
- DA:383,32
230
- DA:384,32
231
- DA:387,32
232
- DA:390,32
233
- DA:391,23
234
- DA:392,65
235
- DA:393,65
236
- DA:394,38
237
- DA:398,9
238
- DA:399,31
239
- DA:403,32
240
- DA:404,32
241
- DA:407,32
242
- DA:408,32
243
- DA:409,3
244
- DA:412,32
245
- LF:139
246
- LH:134
247
- BRDA:88,0,0,32
248
- BRDA:88,0,1,32
249
- BRDA:97,1,0,10
250
- BRDA:97,1,1,32
251
- BRDA:97,2,0,42
252
- BRDA:97,2,1,32
253
- BRDA:103,3,0,29
254
- BRDA:103,3,1,3
255
- BRDA:113,4,0,3
256
- BRDA:113,4,1,39
257
- BRDA:113,5,0,42
258
- BRDA:113,5,1,36
259
- BRDA:118,6,0,41
260
- BRDA:118,6,1,1
261
- BRDA:120,7,0,41
262
- BRDA:120,7,1,0
263
- BRDA:123,8,0,6
264
- BRDA:123,8,1,35
265
- BRDA:128,9,0,41
266
- BRDA:128,9,1,1
267
- BRDA:154,10,0,9
268
- BRDA:154,10,1,27
269
- BRDA:163,11,0,1
270
- BRDA:163,11,1,26
271
- BRDA:179,12,0,13
272
- BRDA:179,12,1,13
273
- BRDA:190,13,0,6
274
- BRDA:190,13,1,56
275
- BRDA:194,14,0,1
276
- BRDA:194,14,1,5
277
- BRDA:194,15,0,6
278
- BRDA:194,15,1,2
279
- BRDA:212,16,0,20
280
- BRDA:212,16,1,6
281
- BRDA:218,17,0,2
282
- BRDA:218,17,1,4
283
- BRDA:223,18,0,6
284
- BRDA:223,18,1,5
285
- BRDA:256,19,0,1
286
- BRDA:256,19,1,31
287
- BRDA:256,20,0,32
288
- BRDA:256,20,1,9
289
- BRDA:267,21,0,24
290
- BRDA:267,21,1,128
291
- BRDA:272,22,0,13
292
- BRDA:272,22,1,19
293
- BRDA:274,23,0,17
294
- BRDA:274,23,1,0
295
- BRDA:274,24,0,17
296
- BRDA:274,24,1,11
297
- BRDA:282,25,0,23
298
- BRDA:282,25,1,9
299
- BRDA:285,26,0,2
300
- BRDA:285,26,1,4
301
- BRDA:290,27,0,21
302
- BRDA:290,27,1,2
303
- BRDA:295,28,0,0
304
- BRDA:295,28,1,11
305
- BRDA:303,29,0,23
306
- BRDA:303,29,1,15
307
- BRDA:308,30,0,0
308
- BRDA:308,30,1,32
309
- BRDA:310,31,0,26
310
- BRDA:310,31,1,6
311
- BRDA:328,32,0,22
312
- BRDA:328,32,1,16
313
- BRDA:349,33,0,37
314
- BRDA:349,33,1,1
315
- BRDA:353,34,0,49
316
- BRDA:353,34,1,8
317
- BRDA:357,35,0,55
318
- BRDA:357,35,1,2
319
- BRDA:371,36,0,2
320
- BRDA:371,36,1,36
321
- BRDA:387,37,0,32
322
- BRDA:387,37,1,32
323
- BRDA:390,38,0,23
324
- BRDA:390,38,1,9
325
- BRDA:393,39,0,38
326
- BRDA:393,39,1,27
327
- BRDA:393,40,0,65
328
- BRDA:393,40,1,62
329
- BRDA:404,41,0,32
330
- BRDA:404,41,1,0
331
- BRDA:408,42,0,3
332
- BRDA:408,42,1,29
333
- BRF:86
334
- BRH:81
335
- end_of_record
336
- TN:
337
- SF:lib/utils.ts
338
- FN:15,getAttr
339
- FN:26,getAttrNesting
340
- FN:38,scoreValue
341
- FN:53,escape_regex
342
- FN:62,propToArray
343
- FN:80,iterate
344
- FN:97,cmp
345
- FNF:7
346
- FNH:7
347
- FNDA:299,getAttr
348
- FNDA:12,getAttrNesting
349
- FNDA:181,scoreValue
350
- FNDA:87,escape_regex
351
- FNDA:113,propToArray
352
- FNDA:105,iterate
353
- FNDA:77,cmp
354
- DA:16,299
355
- DA:17,298
356
- DA:27,12
357
- DA:28,11
358
- DA:29,11
359
- DA:30,11
360
- DA:41,181
361
- DA:43,165
362
- DA:44,165
363
- DA:45,165
364
- DA:47,56
365
- DA:48,56
366
- DA:50,56
367
- DA:54,87
368
- DA:63,113
369
- DA:64,113
370
- DA:65,23
371
- DA:82,105
372
- DA:83,48
373
- DA:87,57
374
- DA:88,139
375
- DA:89,139
376
- DA:98,77
377
- DA:99,23
378
- DA:101,54
379
- DA:102,54
380
- DA:103,54
381
- DA:104,38
382
- DA:105,11
383
- LF:29
384
- LH:29
385
- BRDA:16,0,0,1
386
- BRDA:16,0,1,298
387
- BRDA:27,1,0,1
388
- BRDA:27,1,1,11
389
- BRDA:29,2,0,33
390
- BRDA:29,2,1,22
391
- BRDA:41,3,0,16
392
- BRDA:41,3,1,165
393
- BRDA:45,4,0,109
394
- BRDA:45,4,1,56
395
- BRDA:48,5,0,42
396
- BRDA:48,5,1,14
397
- BRDA:64,6,0,23
398
- BRDA:64,6,1,90
399
- BRDA:64,7,0,113
400
- BRDA:64,7,1,53
401
- BRDA:82,8,0,48
402
- BRDA:82,8,1,57
403
- BRDA:88,9,0,139
404
- BRDA:88,9,1,0
405
- BRDA:98,10,0,23
406
- BRDA:98,10,1,54
407
- BRDA:98,11,0,77
408
- BRDA:98,11,1,23
409
- BRDA:99,12,0,8
410
- BRDA:99,12,1,15
411
- BRDA:99,13,0,6
412
- BRDA:99,13,1,9
413
- BRDA:103,14,0,16
414
- BRDA:103,14,1,38
415
- BRDA:104,15,0,27
416
- BRDA:104,15,1,11
417
- BRF:32
418
- BRH:31
419
- end_of_record
package/release.sh DELETED
@@ -1,112 +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
- # prompt before finalizing
100
- if ! ask "Version $VERSION is ready for release. Are you sure?"; then
101
- echo 'release aborted'
102
- exit
103
- fi
104
-
105
-
106
- git add .
107
- git commit -a -m "v$VERSION Release"
108
- git tag "v$VERSION"
109
- git push origin master
110
- git push origin --tags
111
- npm publish
112
- echo "\033[32mv${VERSION} released\033[0;39m"
@@ -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
- });
@@ -1,40 +0,0 @@
1
- var assert = require('assert');
2
- var Sifter = require('../build/cjs/sifter.js');
3
-
4
- describe('#prepareSearch()', function() {
5
-
6
- it('should normalize options', function() {
7
- var sifter = new Sifter([{fielda: 'a'}, {}]);
8
- var search = sifter.prepareSearch('a', {
9
- fields: [{field: 'fielda'}],
10
- sort: {field: 'fielda'},
11
- sort_empty: {field: 'fielda'}
12
- });
13
- //assert.equal(Array.isArray(search.options.fields), true);
14
- assert.equal(Array.isArray(search.options.sort), true);
15
- assert.equal(Array.isArray(search.options.sort_empty), true);
16
- });
17
-
18
- describe('returned object', function() {
19
- var sifter = new Sifter([{field: 'a'}, {}]);
20
- var search = sifter.prepareSearch('hello world');
21
-
22
- it('should contain "total" (int)', function() {
23
- assert.equal(search.total, 0);
24
- });
25
- it('should contain "tokens" (array)', function() {
26
- assert.equal(Array.isArray(search.tokens), true);
27
- assert.equal(search.tokens.length, 2);
28
- });
29
- it('should contain "items" (array)', function() {
30
- assert.equal(Array.isArray(search.items), true);
31
- assert.equal(search.items.length, 0);
32
- });
33
- it('should contain "options" (array)', function() {
34
- assert.equal(search.options !== null, true);
35
- assert.equal(typeof search.options, 'object');
36
- assert.equal(Array.isArray(search.options), false);
37
- });
38
- });
39
-
40
- });