30 lines
781 B
Plaintext
30 lines
781 B
Plaintext
'use strict';
|
|
|
|
var sequenceMatcher = ({
|
|
token,
|
|
ascending
|
|
}) => {
|
|
const firstChr = token.charAt(0);
|
|
let baseGuesses;
|
|
const startingPoints = ['a', 'A', 'z', 'Z', '0', '1', '9'];
|
|
// lower guesses for obvious starting points
|
|
if (startingPoints.includes(firstChr)) {
|
|
baseGuesses = 4;
|
|
} else if (/\d/.exec(firstChr)) {
|
|
baseGuesses = 10; // digits
|
|
} else {
|
|
// could give a higher base for uppercase,
|
|
// assigning 26 to both upper and lower sequences is more conservative.
|
|
baseGuesses = 26;
|
|
}
|
|
// need to try a descending sequence in addition to every ascending sequence ->
|
|
// 2x guesses
|
|
if (!ascending) {
|
|
baseGuesses *= 2;
|
|
}
|
|
return baseGuesses * token.length;
|
|
};
|
|
|
|
module.exports = sequenceMatcher;
|
|
//# sourceMappingURL=scoring.cjs.map
|