diff --git a/modUtils.js b/modUtils.js index 53a9c69..a2cd3ae 100644 --- a/modUtils.js +++ b/modUtils.js @@ -106,6 +106,7 @@ class ModUtils { } return Object.fromEntries(Object.entries(groups).map(([identifier, groupNumber]) => [identifier, expressionMatchResult[groupNumber]])); } + /** @param {{ [x: string]: string; }} [nameMappings] */ matchRawCode(/** @type {string} */ raw, nameMappings) { const { expression, groups } = this.generateRegularExpression(raw, false, nameMappings); try { @@ -148,8 +149,8 @@ class ModUtils { * @typedef {{ dictionary?: { [x: string]: string } }} BaseOptions * @typedef {BaseOptions & { addToDictionary?: string[] }} MatchCodeOptions */ - matchCode(code, /** @type {MatchCodeOptions=} */ options) { - const result = this.matchRawCode(minifyCode(code)); + matchCode(/** @type {string} */ code, /** @type {MatchCodeOptions=} */ options) { + const result = this.matchRawCode(minifyCode(code), options?.dictionary); if (options?.addToDictionary !== undefined) { options.addToDictionary.forEach(varName => { if (result[varName] === undefined) @@ -185,4 +186,9 @@ class ModUtils { escapeRegExp = escapeRegExp } -export default ModUtils; \ No newline at end of file +export default ModUtils; + +/** @param {(modUtils: ModUtils) => any} callback */ +export function definePatch(callback) { + return (/** @type {ModUtils} */ modUtils) => callback(modUtils) +} \ No newline at end of file