dbgate-tools 4.7.4-alpha.15 → 4.7.4-alpha.16

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 (2) hide show
  1. package/lib/filterName.js +21 -1
  2. package/package.json +4 -4
package/lib/filterName.js CHANGED
@@ -35,6 +35,26 @@ const compact_1 = __importDefault(require("lodash/compact"));
35
35
  // if (Filter.All(Char.IsUpper)) return camelMatch;
36
36
  // return DoMatch(Filter, value) || camelMatch;
37
37
  // }
38
+ function fuzzysearch(needle, haystack) {
39
+ var hlen = haystack.length;
40
+ var nlen = needle.length;
41
+ if (nlen > hlen) {
42
+ return false;
43
+ }
44
+ if (nlen === hlen) {
45
+ return needle === haystack;
46
+ }
47
+ outer: for (var i = 0, j = 0; i < nlen; i++) {
48
+ var nch = needle.charCodeAt(i);
49
+ while (j < hlen) {
50
+ if (haystack.charCodeAt(j++) === nch) {
51
+ continue outer;
52
+ }
53
+ }
54
+ return false;
55
+ }
56
+ return true;
57
+ }
38
58
  function filterName(filter, ...names) {
39
59
  if (!filter)
40
60
  return true;
@@ -43,7 +63,7 @@ function filterName(filter, ...names) {
43
63
  const namesCompacted = (0, compact_1.default)(names);
44
64
  for (const token of tokens) {
45
65
  const tokenUpper = token.toUpperCase();
46
- const found = namesCompacted.find(name => name.toUpperCase().includes(tokenUpper));
66
+ const found = namesCompacted.find(name => fuzzysearch(tokenUpper, name.toUpperCase()));
47
67
  if (!found)
48
68
  return false;
49
69
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.7.4-alpha.15",
2
+ "version": "4.7.4-alpha.16",
3
3
  "name": "dbgate-tools",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -25,15 +25,15 @@
25
25
  ],
26
26
  "devDependencies": {
27
27
  "@types/node": "^13.7.0",
28
- "dbgate-types": "^4.7.4-alpha.15",
28
+ "dbgate-types": "^4.7.4-alpha.16",
29
29
  "jest": "^24.9.0",
30
30
  "ts-jest": "^25.2.1",
31
31
  "typescript": "^4.4.3"
32
32
  },
33
33
  "dependencies": {
34
34
  "lodash": "^4.17.21",
35
- "dbgate-query-splitter": "^4.7.4-alpha.15",
36
- "dbgate-sqltree": "^4.7.4-alpha.15",
35
+ "dbgate-query-splitter": "^4.7.4-alpha.16",
36
+ "dbgate-sqltree": "^4.7.4-alpha.16",
37
37
  "uuid": "^3.4.0"
38
38
  }
39
39
  }