]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/atom-space-pen-views/node_modules/fuzzaldrin/lib/fuzzaldrin.js
41755d2f8da6e83f43bf34b9598197b17efd23de
2 var PathSeparator
, SpaceRegex
, filter
, matcher
, scorer
;
4 scorer
= require('./scorer');
6 filter
= require('./filter');
8 matcher
= require('./matcher');
10 PathSeparator
= require('path').sep
;
15 filter: function(candidates
, query
, options
) {
18 queryHasSlashes
= query
.indexOf(PathSeparator
) !== -1;
19 query
= query
.replace(SpaceRegex
, '');
21 return filter(candidates
, query
, queryHasSlashes
, options
);
23 score: function(string
, query
) {
24 var queryHasSlashes
, score
;
31 if (string
=== query
) {
34 queryHasSlashes
= query
.indexOf(PathSeparator
) !== -1;
35 query
= query
.replace(SpaceRegex
, '');
36 score
= scorer
.score(string
, query
);
37 if (!queryHasSlashes
) {
38 score
= scorer
.basenameScore(string
, query
, score
);
42 match: function(string
, query
) {
43 var baseMatches
, index
, matches
, queryHasSlashes
, seen
, _i
, _ref
, _results
;
50 if (string
=== query
) {
53 for (var _i
= 0, _ref
= string
.length
; 0 <= _ref
? _i
< _ref : _i
> _ref
; 0 <= _ref
? _i
++ : _i
--){ _results
.push(_i
); }
57 queryHasSlashes
= query
.indexOf(PathSeparator
) !== -1;
58 query
= query
.replace(SpaceRegex
, '');
59 matches
= matcher
.match(string
, query
);
60 if (!queryHasSlashes
) {
61 baseMatches
= matcher
.basenameMatch(string
, query
);
62 matches
= matches
.concat(baseMatches
).sort(function(a
, b
) {
67 while (index
< matches
.length
) {
68 if (index
&& seen
=== matches
[index
]) {
69 matches
.splice(index
, 1);
71 seen
= matches
[index
];