Change to prototype keys

This commit is contained in:
Zack Rauen 2023-05-24 18:24:18 -04:00
parent 83c0c81079
commit 0acc5a6f85
3 changed files with 21 additions and 16 deletions

View File

@ -44,12 +44,17 @@ const Webpack = {
*/
byKeys(...keys) {return Filters.byKeys(keys);},
/**
* @deprecated
*/
byPrototypeFields(...props) {return Filters.byPrototypeKeys(props);},
/**
* Generates a function that filters by a set of properties on the object's prototype.
* @param {...string} props List of property names
* @returns {function} A filter that checks for a set of properties on the object's prototype.
*/
byPrototypeFields(...props) {return Filters.byPrototypeFields(props);},
byPrototypeKeys(...props) {return Filters.byPrototypeKeys(props);},
/**
* Generates a function that filters by a regex.
@ -114,10 +119,16 @@ const Webpack = {
return WebpackModules.getModule(filter, options);
},
/**
* Finds all modules matching a filter function.
* @param {Function} filter A function to use to filter modules
*/
getAll(filter) {return WebpackModules.getModule(filter, {first: false});},
/**
* @deprecated
*/
getModule() {return this.get.apply(this, arguments);},
getModule() {return Webpack.get(...arguments);},
/**
* Finds multiple modules using multiple filters.
@ -148,12 +159,6 @@ const Webpack = {
return WebpackModules.getLazy(filter, options);
},
/**
* Finds all modules matching a filter function.
* @param {Function} filter A function to use to filter modules
*/
getModules(filter) {return WebpackModules.getModule(filter, {first: false});},
/**
* Finds a module using its code.
* @param {RegEx} regex A regular expression to use to filter modules
@ -183,10 +188,10 @@ const Webpack = {
* @param {...string} prototypes Properties to use to filter modules
* @return {Any}
*/
getByPrototypes(...prototypes) {
getByPrototypeKeys(...prototypes) {
const options = getOptions(prototypes);
return WebpackModules.getModule(Filters.byPrototypeFields(prototypes), options);
return WebpackModules.getModule(Filters.byPrototypeKeys(prototypes), options);
},
/**
@ -194,10 +199,10 @@ const Webpack = {
* @param {...string} prototypes Properties to use to filter modules
* @return {Any[]}
*/
getAllByPrototypeFields(...prototypes) {
getAllByPrototypeKeys(...prototypes) {
const options = getOptions(prototypes, {first: false});
return WebpackModules.getModule(Filters.byPrototypeFields(prototypes), options);
return WebpackModules.getModule(Filters.byPrototypeKeys(prototypes), options);
},
/**

View File

@ -41,7 +41,7 @@ export class Filters {
* @param {module:WebpackModules.Filters~filter} filter - Additional filter
* @returns {module:WebpackModules.Filters~filter} - A filter that checks for a set of properties on the object's prototype
*/
static byPrototypeFields(fields, filter = m => m) {
static byPrototypeKeys(fields, filter = m => m) {
return module => {
if (!module) return false;
if (typeof(module) !== "object" && typeof(module) !== "function") return false;
@ -315,7 +315,7 @@ export default class WebpackModules {
* @return {Any}
*/
static getByPrototypes(...prototypes) {
return this.getModule(Filters.byPrototypeFields(prototypes));
return this.getModule(Filters.byPrototypeKeys(prototypes));
}
/**
@ -324,7 +324,7 @@ export default class WebpackModules {
* @return {Any}
*/
static getAllByPrototypes(...prototypes) {
return this.getModule(Filters.byPrototypeFields(prototypes), {first: false});
return this.getModule(Filters.byPrototypeKeys(prototypes), {first: false});
}
/**

View File

@ -62,7 +62,7 @@ export default new class SettingsRenderer {
}
async patchSections() {
const UserSettings = await WebpackModules.getLazy(Filters.byPrototypeFields(["getPredicateSections"]));
const UserSettings = await WebpackModules.getLazy(Filters.byPrototypeKeys(["getPredicateSections"]));
Patcher.after("SettingsManager", UserSettings.prototype, "getPredicateSections", (thisObject, args, returnValue) => {
let location = returnValue.findIndex(s => s.section.toLowerCase() == "changelog") - 1;