Files
SnowLuma/.pnpm-store/v11/files/bb/4dd882ca5ac43184162991e5799cb892149f1dc232f8f6ecd0751157587a554955f43fe3049f1b1cf0f50a04b9ad017af35b90869595de5975a3ce08195c00
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Skipped
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

82 lines
2.8 KiB
Plaintext

'use strict';
var helper = require('./utils/helper.cjs');
var matching$7 = require('./matcher/date/matching.cjs');
var matching$6 = require('./matcher/dictionary/matching.cjs');
var l33t = require('./matcher/dictionary/variants/matching/l33t.cjs');
var reverse = require('./matcher/dictionary/variants/matching/reverse.cjs');
var matching$5 = require('./matcher/regex/matching.cjs');
var matching$4 = require('./matcher/repeat/matching.cjs');
var matching$3 = require('./matcher/sequence/matching.cjs');
var matching$2 = require('./matcher/spatial/matching.cjs');
var matching$1 = require('./matcher/separator/matching.cjs');
var matching = require('./matcher/wordSequence/matching.cjs');
/*
* -------------------------------------------------------------------------------
* Omnimatch combine matchers ---------------------------------------------------------------
* -------------------------------------------------------------------------------
*/
class Matching {
constructor(options) {
this.options = options;
this.matchers = {};
this.matchers = {
date: new matching$7(this.options),
dictionary: new matching$6(this.options),
dictionaryL33t: new l33t(this.options),
dictionaryReverse: new reverse(this.options),
regex: new matching$5(this.options),
repeat: new matching$4(this.options),
sequence: new matching$3(this.options),
spatial: new matching$2(this.options),
separator: new matching$1(this.options),
wordSequence: new matching(this.options)
};
Object.entries(this.options.matchers).forEach(([key, Matcher]) => {
this.matchers[key] = new Matcher.Matching(this.options);
});
}
processResult(matches, promises, result) {
if (result instanceof Promise) {
const wrappedPromise = result.then(response => {
helper.extend(matches, response);
return response;
});
promises.push(wrappedPromise);
} else {
helper.extend(matches, result);
}
}
handlePromises(matches, promises) {
if (promises.length > 0) {
return new Promise((resolve, reject) => {
Promise.all(promises).then(() => {
resolve(helper.sorted(matches));
}).catch(error => {
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
reject(error);
});
});
}
return helper.sorted(matches);
}
match(password, userInputsOptions) {
const matches = [];
const promises = [];
Object.values(this.matchers).forEach(matcher => {
const result = matcher.match({
password,
omniMatch: this,
userInputsOptions
});
// extends matches and promises by references
this.processResult(matches, promises, result);
});
return this.handlePromises(matches, promises);
}
}
module.exports = Matching;
//# sourceMappingURL=Matching.cjs.map