30 lines
918 B
Plaintext
30 lines
918 B
Plaintext
'use strict';
|
|
|
|
var matching = require('../../matching.cjs');
|
|
|
|
/*
|
|
* -------------------------------------------------------------------------------
|
|
* Dictionary reverse matching --------------------------------------------------
|
|
* -------------------------------------------------------------------------------
|
|
*/
|
|
class MatchReverse extends matching {
|
|
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
|
|
}));
|
|
}
|
|
}
|
|
|
|
module.exports = MatchReverse;
|
|
//# sourceMappingURL=reverse.cjs.map
|