Files
SnowLuma/.pnpm-store/v11/files/eb/6880f00e05bc04de96bc4d54d13cf570878c743fd2a22c91caeb2162c9d8d8cc8c624e4ebacbea3dfe98dd8977eda4dc5f465271f4b1979c09cde2680006b7
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

30 lines
1.0 KiB
Plaintext

import MatchDictionary from '../../matching'
import { DictionaryMatch } from '../../../../types'
import { DictionaryMatchOptions } from '../../types'
/*
* -------------------------------------------------------------------------------
* Dictionary reverse matching --------------------------------------------------
* -------------------------------------------------------------------------------
*/
class MatchReverse extends MatchDictionary {
public match(matchOptions: DictionaryMatchOptions) {
const passwordReversed = matchOptions.password.split('').reverse().join('')
return super
.match({
...matchOptions,
password: passwordReversed,
})
.map((match: DictionaryMatch) => ({
...match,
token: match.token.split('').reverse().join(''), // reverse back
reversed: true,
// map coordinates back to original string
i: matchOptions.password.length - 1 - match.j,
j: matchOptions.password.length - 1 - match.i,
}))
}
}
export default MatchReverse