Change to prototype keys
This commit is contained in:
parent
83c0c81079
commit
0acc5a6f85
|
@ -44,12 +44,17 @@ const Webpack = {
|
||||||
*/
|
*/
|
||||||
byKeys(...keys) {return Filters.byKeys(keys);},
|
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.
|
* Generates a function that filters by a set of properties on the object's prototype.
|
||||||
* @param {...string} props List of property names
|
* @param {...string} props List of property names
|
||||||
* @returns {function} A filter that checks for a set of properties on the object's prototype.
|
* @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.
|
* Generates a function that filters by a regex.
|
||||||
|
@ -114,10 +119,16 @@ const Webpack = {
|
||||||
return WebpackModules.getModule(filter, options);
|
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
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
getModule() {return this.get.apply(this, arguments);},
|
getModule() {return Webpack.get(...arguments);},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds multiple modules using multiple filters.
|
* Finds multiple modules using multiple filters.
|
||||||
|
@ -148,12 +159,6 @@ const Webpack = {
|
||||||
return WebpackModules.getLazy(filter, options);
|
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.
|
* Finds a module using its code.
|
||||||
* @param {RegEx} regex A regular expression to use to filter modules
|
* @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
|
* @param {...string} prototypes Properties to use to filter modules
|
||||||
* @return {Any}
|
* @return {Any}
|
||||||
*/
|
*/
|
||||||
getByPrototypes(...prototypes) {
|
getByPrototypeKeys(...prototypes) {
|
||||||
const options = getOptions(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
|
* @param {...string} prototypes Properties to use to filter modules
|
||||||
* @return {Any[]}
|
* @return {Any[]}
|
||||||
*/
|
*/
|
||||||
getAllByPrototypeFields(...prototypes) {
|
getAllByPrototypeKeys(...prototypes) {
|
||||||
const options = getOptions(prototypes, {first: false});
|
const options = getOptions(prototypes, {first: false});
|
||||||
|
|
||||||
return WebpackModules.getModule(Filters.byPrototypeFields(prototypes), options);
|
return WebpackModules.getModule(Filters.byPrototypeKeys(prototypes), options);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,7 +41,7 @@ export class Filters {
|
||||||
* @param {module:WebpackModules.Filters~filter} filter - Additional filter
|
* @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
|
* @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 => {
|
return module => {
|
||||||
if (!module) return false;
|
if (!module) return false;
|
||||||
if (typeof(module) !== "object" && typeof(module) !== "function") return false;
|
if (typeof(module) !== "object" && typeof(module) !== "function") return false;
|
||||||
|
@ -315,7 +315,7 @@ export default class WebpackModules {
|
||||||
* @return {Any}
|
* @return {Any}
|
||||||
*/
|
*/
|
||||||
static getByPrototypes(...prototypes) {
|
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}
|
* @return {Any}
|
||||||
*/
|
*/
|
||||||
static getAllByPrototypes(...prototypes) {
|
static getAllByPrototypes(...prototypes) {
|
||||||
return this.getModule(Filters.byPrototypeFields(prototypes), {first: false});
|
return this.getModule(Filters.byPrototypeKeys(prototypes), {first: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default new class SettingsRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
async patchSections() {
|
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) => {
|
Patcher.after("SettingsManager", UserSettings.prototype, "getPredicateSections", (thisObject, args, returnValue) => {
|
||||||
let location = returnValue.findIndex(s => s.section.toLowerCase() == "changelog") - 1;
|
let location = returnValue.findIndex(s => s.section.toLowerCase() == "changelog") - 1;
|
||||||
|
|
Loading…
Reference in New Issue