28 lines
919 B
Plaintext
28 lines
919 B
Plaintext
import MatchDictionary from '../../matching.mjs';
|
|
|
|
/*
|
|
* -------------------------------------------------------------------------------
|
|
* Dictionary reverse matching --------------------------------------------------
|
|
* -------------------------------------------------------------------------------
|
|
*/
|
|
class MatchReverse extends MatchDictionary {
|
|
match(matchOptions) {
|
|
const passwordReversed = matchOptions.password.split('').reverse().join('');
|
|
return super.match({
|
|
...matchOptions,
|
|
password: passwordReversed
|
|
}).map(match => ({
|
|
...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 { MatchReverse as default };
|
|
//# sourceMappingURL=reverse.mjs.map
|