@orchidjs/sifter 1.0.2 → 1.1.0

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 (41) hide show
  1. package/dist/cjs/package.json +1 -0
  2. package/dist/cjs/sifter.d.ts +72 -0
  3. package/dist/cjs/sifter.js +290 -1110
  4. package/dist/cjs/sifter.js.map +1 -1
  5. package/dist/cjs/types.d.ts +57 -0
  6. package/dist/cjs/types.js +3 -0
  7. package/dist/cjs/types.js.map +1 -0
  8. package/dist/cjs/utils.d.ts +48 -0
  9. package/dist/cjs/utils.js +102 -0
  10. package/dist/cjs/utils.js.map +1 -0
  11. package/dist/esm/sifter.d.ts +72 -0
  12. package/dist/esm/sifter.js +267 -330
  13. package/dist/esm/sifter.js.map +1 -1
  14. package/dist/esm/types.d.ts +57 -0
  15. package/dist/esm/types.js +2 -0
  16. package/dist/esm/types.js.map +1 -0
  17. package/dist/esm/utils.d.ts +48 -0
  18. package/dist/esm/utils.js +54 -56
  19. package/dist/esm/utils.js.map +1 -1
  20. package/dist/types/sifter.d.ts +3 -2
  21. package/dist/types/types.d.ts +12 -12
  22. package/dist/types/utils.d.ts +2 -2
  23. package/dist/umd/package.json +1 -0
  24. package/dist/umd/sifter.js +794 -1043
  25. package/dist/umd/sifter.js.map +1 -1
  26. package/dist/umd/sifter.min.js +72 -77
  27. package/dist/umd/sifter.min.js.map +1 -1
  28. package/lib/sifter.ts +3 -2
  29. package/lib/types.ts +1 -1
  30. package/lib/utils.ts +1 -1
  31. package/package.json +31 -21
  32. package/dist/esm/lib/sifter.js +0 -368
  33. package/dist/esm/lib/sifter.js.map +0 -1
  34. package/dist/esm/lib/utils.js +0 -95
  35. package/dist/esm/lib/utils.js.map +0 -1
  36. package/dist/esm/node_modules/@orchidjs/unicode-variants/dist/esm/index.js +0 -556
  37. package/dist/esm/node_modules/@orchidjs/unicode-variants/dist/esm/index.js.map +0 -1
  38. package/dist/esm/node_modules/@orchidjs/unicode-variants/dist/esm/regex.js +0 -113
  39. package/dist/esm/node_modules/@orchidjs/unicode-variants/dist/esm/regex.js.map +0 -1
  40. package/dist/esm/node_modules/@orchidjs/unicode-variants/dist/esm/strings.js +0 -29
  41. package/dist/esm/node_modules/@orchidjs/unicode-variants/dist/esm/strings.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * sifter.js
3
+ * Copyright (c) 2013–2020 Brian Reavis & contributors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6
+ * file except in compliance with the License. You may obtain a copy of the License at:
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ * ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ *
14
+ * @author Brian Reavis <brian@thirdroute.com>
15
+ */
16
+ import { scoreValue, getAttr, getAttrNesting, propToArray, iterate, cmp } from './utils.ts';
17
+ import { getPattern } from '@orchidjs/unicode-variants';
18
+ import * as T from './types.ts';
19
+ declare class Sifter {
20
+ items: any;
21
+ settings: T.Settings;
22
+ /**
23
+ * Textually searches arrays and hashes of objects
24
+ * by property (or multiple properties). Designed
25
+ * specifically for autocomplete.
26
+ *
27
+ */
28
+ constructor(items: any, settings: T.Settings);
29
+ /**
30
+ * Splits a search string into an array of individual
31
+ * regexps to be used to match results.
32
+ *
33
+ */
34
+ tokenize(query: string, respect_word_boundaries?: boolean, weights?: T.Weights): T.Token[];
35
+ /**
36
+ * Returns a function to be used to score individual results.
37
+ *
38
+ * Good matches will have a higher score than poor matches.
39
+ * If an item is not a match, 0 will be returned by the function.
40
+ *
41
+ * @returns {T.ScoreFn}
42
+ */
43
+ getScoreFunction(query: string, options: T.UserOptions): (data: {}) => number;
44
+ /**
45
+ * @returns {T.ScoreFn}
46
+ *
47
+ */
48
+ _getScoreFunction(search: T.PrepareObj): (data: {}) => number;
49
+ /**
50
+ * Returns a function that can be used to compare two
51
+ * results, for sorting purposes. If no sorting should
52
+ * be performed, `null` will be returned.
53
+ *
54
+ * @return function(a,b)
55
+ */
56
+ getSortFunction(query: string, options: T.UserOptions): ((a: T.ResultItem, b: T.ResultItem) => number) | null;
57
+ _getSortFunction(search: T.PrepareObj): ((a: T.ResultItem, b: T.ResultItem) => number) | null;
58
+ /**
59
+ * Parses a search query and returns an object
60
+ * with tokens and fields ready to be populated
61
+ * with results.
62
+ *
63
+ */
64
+ prepareSearch(query: string, optsUser: T.UserOptions): T.PrepareObj;
65
+ /**
66
+ * Searches through all items and returns a sorted array of matches.
67
+ *
68
+ */
69
+ search(query: string, options: T.UserOptions): T.PrepareObj;
70
+ }
71
+ export { Sifter, scoreValue, getAttr, getAttrNesting, propToArray, iterate, cmp, getPattern };
72
+ export * from './types.ts';