aboutsummaryrefslogtreecommitdiff
path: root/src/webpack/webpack.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/webpack/webpack.ts')
-rw-r--r--src/webpack/webpack.ts25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts
index bd06b03..0bbd815 100644
--- a/src/webpack/webpack.ts
+++ b/src/webpack/webpack.ts
@@ -16,11 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import Logger from "@utils/Logger";
+import { proxyLazy } from "@utils/proxyLazy";
import type { WebpackInstance } from "discord-types/other";
import { traceFunction } from "../debug/Tracer";
-import Logger from "../utils/Logger";
-import { proxyLazy } from "../utils/proxyLazy";
const logger = new Logger("Webpack");
@@ -113,6 +113,13 @@ export const find = traceFunction("find", function find(filter: FilterFn, getDef
return null;
});
+/**
+ * find but lazy
+ */
+export function findLazy(filter: FilterFn, getDefault = true) {
+ return proxyLazy(() => find(filter, getDefault));
+}
+
export function findAll(filter: FilterFn, getDefault = true) {
if (typeof filter !== "function")
throw new Error("Invalid filter. Expected a function got " + typeof filter);
@@ -292,6 +299,13 @@ export function findByProps(...props: string[]) {
}
/**
+ * findByProps but lazy
+ */
+export function findByPropsLazy(...props: string[]) {
+ return findLazy(filters.byProps(...props));
+}
+
+/**
* Find all modules that have the specified properties
*/
export function findAllByProps(...props: string[]) {
@@ -306,6 +320,13 @@ export function findByCode(...code: string[]) {
}
/**
+ * findByCode but lazy
+ */
+export function findByCodeLazy(...code: string[]) {
+ return findLazy(filters.byCode(...code));
+}
+
+/**
* Wait for a module that matches the provided filter to be registered,
* then call the callback with the module as the first argument
*/