Permalink
Browse files

Remove old sorting method and reference 'relevancy' (previously named…

… 'similarity')
  • Loading branch information...
1 parent b043e12 commit 6744791ce2cc0c901658f7761963bc9580ba9577 @padolsey committed Nov 22, 2011
Showing with 2 additions and 33 deletions.
  1. +2 −33 app/jsapi/jsapi.sourcehandler.resolver.js
@@ -1,5 +1,5 @@
var log = require('./jsapi.log.js'),
- similarity = require('similarity');
+ relevancy = require('relevancy');
/**
* SourceHandler.Resolver
@@ -122,7 +122,7 @@ Resolver.prototype = {
}
}
- return methodName ? similarity.sort(
+ return methodName ? relevancy.sort(
ret.map(function(item){
item.toString = function() {
return this.name;
@@ -132,37 +132,6 @@ Resolver.prototype = {
methodName
) : ret;
- },
-
- sortMethodsBySimilarityTo: function(methods, to) {
-
- var regex = (function(){
- for (var ret = [], i = to.length; i--;)
- ret.push(to.replace(/[-[\]{}()*+?.,\\^$#\s|]/g, "\\$&").slice(0, i + 1));
- return RegExp(ret.join('|'), 'ig');
- }());
-
- return methods.sort(function(a,b){
-
- a = a.name;
- b = b.name;
-
- regex.lastIndex = 0;
- var matchA = (regex.exec(a)||['']).sort()[0],
- iA = (regex.lastIndex - matchA.length) * matchA.length - matchA.length;
-
- regex.lastIndex = 0;
-
- var matchB = (regex.exec(b)||['']).sort()[0],
- iB = (regex.lastIndex - matchB.length) * matchB.length - matchB.length;
-
- //console.log(a, matchA, iA, '->', (iB < iA ? 1 : -1));
- //console.log(b, matchB, iB);
- return matchA && matchB ?
- (iB < iA ? 1 : -1)
- : matchA ? -1 : 1;
- });
-
}
};

0 comments on commit 6744791

Please sign in to comment.