mergeMatches = function(a, b) { var ai, bj, i, j, m, n, out;
m = a.length;
n = b.length; if (n === 0) { return a.slice();
} if (m === 0) { return b.slice();
}
i = -1;
j = 0;
bj = b[j];
out = []; while (++i < m) {
ai = a[i]; while (bj <= ai && ++j < n) { if (bj < ai) {
out.push(bj);
}
bj = b[j];
}
out.push(ai);
} while (j < n) {
out.push(b[j++]);
} return out;
};
computeMatch = function(subject, subject_lw, preparedQuery, offset) { var DIAGONAL, LEFT, STOP, UP, acro_score, align, backtrack, csc_diag, csc_row, csc_score, i, j, m, matches, move, n, pos, query, query_lw, score, score_diag, score_row, score_up, si_lw, start, trace; if (offset == null) {
offset = 0;
}
query = preparedQuery.query;
query_lw = preparedQuery.query_lw;
m = subject.length;
n = query.length;
acro_score = scoreAcronyms(subject, subject_lw, query, query_lw).score;
score_row = new Array(n);
csc_row = new Array(n);
STOP = 0;
UP = 1;
LEFT = 2;
DIAGONAL = 3;
trace = new Array(m * n);
pos = -1;
j = -1; while (++j < n) {
score_row[j] = 0;
csc_row[j] = 0;
}
i = -1; while (++i < m) {
score = 0;
score_up = 0;
csc_diag = 0;
si_lw = subject_lw[i];
j = -1; while (++j < n) {
csc_score = 0;
align = 0;
score_diag = score_up; if (query_lw[j] === si_lw) {
start = isWordStart(i, subject, subject_lw);
csc_score = csc_diag > 0 ? csc_diag : scoreConsecutives(subject, subject_lw, query, query_lw, i, j, start);
align = score_diag + scoreCharacter(i, j, start, acro_score, csc_score);
}
score_up = score_row[j];
csc_diag = csc_row[j]; if (score > score_up) {
move = LEFT;
} else {
score = score_up;
move = UP;
} if (align > score) {
score = align;
move = DIAGONAL;
} else {
csc_score = 0;
}
score_row[j] = score;
csc_row[j] = csc_score;
trace[++pos] = score > 0 ? move : STOP;
}
}
i = m - 1;
j = n - 1;
pos = i * n + j;
backtrack = true;
matches = []; while (backtrack && i >= 0 && j >= 0) { switch (trace[pos]) { case UP:
i--;
pos -= n; break; case LEFT:
j--;
pos--; break; case DIAGONAL:
matches.push(i + offset);
j--;
i--;
pos -= n + 1; break; default:
backtrack = false;
}
}
matches.reverse(); return matches;
};
exports.isMatch = isMatch = function(subject, query_lw, query_up) { var i, j, m, n, qj_lw, qj_up, si;
m = subject.length;
n = query_lw.length; if (!m || n > m) { returnfalse;
}
i = -1;
j = -1; while (++j < n) {
qj_lw = query_lw.charCodeAt(j);
qj_up = query_up.charCodeAt(j); while (++i < m) {
si = subject.charCodeAt(i); if (si === qj_lw || si === qj_up) { break;
}
} if (i === m) { returnfalse;
}
} returntrue;
};
emptyAcronymResult = new AcronymResult(0, 0.1, 0);
exports.scoreAcronyms = scoreAcronyms = function(subject, subject_lw, query, query_lw) { var count, fullWord, i, j, m, n, qj_lw, sameCase, score, sepCount, sumPos;
m = subject.length;
n = query.length; if (!(m > 1 && n > 1)) { return emptyAcronymResult;
}
count = 0;
sepCount = 0;
sumPos = 0;
sameCase = 0;
i = -1;
j = -1; while (++j < n) {
qj_lw = query_lw[j]; if (isSeparator(qj_lw)) {
i = subject_lw.indexOf(qj_lw, i + 1); if (i > -1) {
sepCount++; continue;
} else { break;
}
} while (++i < m) { if (qj_lw === subject_lw[i] && isWordStart(i, subject, subject_lw)) { if (query[j] === subject[i]) {
sameCase++;
}
sumPos += i;
count++; break;
}
} if (i === m) { break;
}
} if (count < 2) { return emptyAcronymResult;
}
fullWord = count === n ? isAcronymFullWord(subject, subject_lw, query, count) : false;
score = scorePattern(count, n, sameCase, true, fullWord); returnnew AcronymResult(score, sumPos / count, count + sepCount);
};
isAcronymFullWord = function(subject, subject_lw, query, nbAcronymInQuery) { var count, i, m, n;
m = subject.length;
n = query.length;
count = 0; if (m > 12 * n) { returnfalse;
}
i = -1; while (++i < m) { if (isWordStart(i, subject, subject_lw) && ++count > nbAcronymInQuery) { returnfalse;
}
} returntrue;
};
}).call(this);
},{}],7:[function(require,module,exports){ // shim for using process in browser var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines.
var cachedSetTimeout; var cachedClearTimeout;
function defaultSetTimout() { thrownew Error('setTimeout has not been defined');
} function defaultClearTimeout () { thrownew Error('clearTimeout has not been defined');
}
(function () { try { if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
} try { if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0);
} // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout; return setTimeout(fun, 0);
} try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0);
} catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0);
} catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0);
}
}
} function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker);
} // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout; return clearTimeout(marker);
} try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker);
} catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker);
} catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker);
}
}
} var queue = []; var draining = false; var currentQueue; var queueIndex = -1;
function cleanUpNextTick() { if (!draining || !currentQueue) { return;
}
draining = false; if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
} if (queue.length) {
drainQueue();
}
}
function drainQueue() { if (draining) { return;
} var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length; while(len) {
currentQueue = queue;
queue = []; while (++queueIndex < len) { if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.