diff options
author | Nuckyz <61953774+Nuckyz@users.noreply.github.com> | 2023-02-08 17:48:26 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-08 21:48:26 +0100 |
commit | 291f38115c40c209c88ce509d5163375b34d04a9 (patch) | |
tree | 8594e7dbd6d4933303be62f0eb7950b3f6a18356 /src | |
parent | 8a5218937838a9bc7e40304b885af2a30adfbff1 (diff) | |
download | Vencord-291f38115c40c209c88ce509d5163375b34d04a9.tar.gz Vencord-291f38115c40c209c88ce509d5163375b34d04a9.tar.bz2 Vencord-291f38115c40c209c88ce509d5163375b34d04a9.zip |
New webpack filter: byDisplayName (#474)
Diffstat (limited to 'src')
-rw-r--r-- | src/webpack/webpack.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 0bbd815..e537740 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -50,6 +50,8 @@ export const filters = { } return true; }, + byDisplayName: (name: string): FilterFn => m => + m.constructor?.displayName === name }; export const subscriptions = new Map<FilterFn, CallbackFn>(); @@ -327,6 +329,20 @@ export function findByCodeLazy(...code: string[]) { } /** + * Find a store by its displayName + */ +export function findByDisplayName(name: string) { + return find(filters.byDisplayName(name)); +} + +/** + * findByDisplayName but lazy + */ +export function findByDisplayNameLazy(name: string) { + return findLazy(filters.byDisplayName(name)); +} + +/** * Wait for a module that matches the provided filter to be registered, * then call the callback with the module as the first argument */ |