/usr/lib/nodejs/fuzzaldrin-plus/lib/fuzzaldrin.js is in node-fuzzaldrin-plus 0.3.1+git.20161008.da2cb58+dfsg-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | (function() {
var Query, defaultPathSeparator, filter, matcher, parseOptions, pathScorer, preparedQueryCache, scorer;
filter = require('./filter');
matcher = require('./matcher');
scorer = require('./scorer');
pathScorer = require('./pathScorer');
Query = require('./query');
preparedQueryCache = null;
defaultPathSeparator = '/';
module.exports = {
filter: function(candidates, query, options) {
if (options == null) {
options = {};
}
if (!((query != null ? query.length : void 0) && (candidates != null ? candidates.length : void 0))) {
return [];
}
options = parseOptions(options, query);
return filter(candidates, query, options);
},
score: function(string, query, options) {
if (options == null) {
options = {};
}
if (!((string != null ? string.length : void 0) && (query != null ? query.length : void 0))) {
return 0;
}
options = parseOptions(options, query);
if (options.usePathScoring) {
return pathScorer.score(string, query, options);
} else {
return scorer.score(string, query, options);
}
},
match: function(string, query, options) {
var i, ref, results;
if (options == null) {
options = {};
}
if (!string) {
return [];
}
if (!query) {
return [];
}
if (string === query) {
return (function() {
results = [];
for (var i = 0, ref = string.length; 0 <= ref ? i < ref : i > ref; 0 <= ref ? i++ : i--){ results.push(i); }
return results;
}).apply(this);
}
options = parseOptions(options, query);
return matcher.match(string, query, options);
},
wrap: function(string, query, options) {
if (options == null) {
options = {};
}
if (!string) {
return [];
}
if (!query) {
return [];
}
options = parseOptions(options, query);
return matcher.wrap(string, query, options);
},
prepareQuery: function(query, options) {
if (options == null) {
options = {};
}
options = parseOptions(options, query);
return options.preparedQuery;
}
};
parseOptions = function(options, query) {
if (options.allowErrors == null) {
options.allowErrors = false;
}
if (options.usePathScoring == null) {
options.usePathScoring = true;
}
if (options.useExtensionBonus == null) {
options.useExtensionBonus = false;
}
if (options.pathSeparator == null) {
options.pathSeparator = defaultPathSeparator;
}
if (options.optCharRegEx == null) {
options.optCharRegEx = null;
}
if (options.wrap == null) {
options.wrap = null;
}
if (options.preparedQuery == null) {
options.preparedQuery = preparedQueryCache && preparedQueryCache.query === query ? preparedQueryCache : (preparedQueryCache = new Query(query, options));
}
return options;
};
}).call(this);
|