Files
SnowLuma/.pnpm-store/v11/files/79/f32b7b0b5a07273784cdd108656252b360bcf83be0b6c9033a5bf567085c8400670a716c3261536d8d648308c19b95245319d9e4d10eef2a92f5fb7edf8fd9
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

24 lines
767 B
Plaintext

import { MatchEstimated, MatchExtended } from '../../types'
export default ({ token, ascending }: MatchExtended | MatchEstimated) => {
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
}