[Utils > without] Move to util
This commit is contained in:
parent
f89238cfce
commit
c4a25744d4
4 changed files with 13 additions and 12 deletions
1
src/def.d.ts
vendored
1
src/def.d.ts
vendored
|
@ -390,6 +390,7 @@ interface VendettaObject {
|
||||||
findInTree: (tree: SearchTree, filter: SearchFilter, options: FindInTreeOptions) => any;
|
findInTree: (tree: SearchTree, filter: SearchFilter, options: FindInTreeOptions) => any;
|
||||||
safeFetch: (input: RequestInfo | URL, options?: RequestInit) => Promise<Response>;
|
safeFetch: (input: RequestInfo | URL, options?: RequestInit) => Promise<Response>;
|
||||||
unfreeze: (obj: object) => object;
|
unfreeze: (obj: object) => object;
|
||||||
|
without: <O extends object, K extends readonly (keyof O)[]>(object: O, ...keys: K) => Omit<O, typeof keys[number]>;
|
||||||
};
|
};
|
||||||
debug: {
|
debug: {
|
||||||
connectToDebugger: (url: string) => void;
|
connectToDebugger: (url: string) => void;
|
||||||
|
|
|
@ -2,4 +2,5 @@
|
||||||
export { default as findInReactTree } from "@utils/findInReactTree";
|
export { default as findInReactTree } from "@utils/findInReactTree";
|
||||||
export { default as findInTree } from "@utils/findInTree";
|
export { default as findInTree } from "@utils/findInTree";
|
||||||
export { default as safeFetch } from "@utils/safeFetch";
|
export { default as safeFetch } from "@utils/safeFetch";
|
||||||
export { default as unfreeze } from "@utils/unfreeze";
|
export { default as unfreeze } from "@utils/unfreeze";
|
||||||
|
export { default as without } from "@utils/without";
|
5
src/lib/utils/without.ts
Normal file
5
src/lib/utils/without.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
export default function without<O extends object, K extends readonly (keyof O)[]>(object: O, ...keys: K): Omit<O, typeof keys[number]> {
|
||||||
|
const cloned = { ...object };
|
||||||
|
keys.forEach((k) => delete cloned[k]);
|
||||||
|
return cloned;
|
||||||
|
}
|
|
@ -17,18 +17,12 @@ import * as assets from "@ui/assets";
|
||||||
import * as color from "@ui/color";
|
import * as color from "@ui/color";
|
||||||
import * as utils from "@utils";
|
import * as utils from "@utils";
|
||||||
|
|
||||||
function without<O extends object, K extends readonly (keyof O)[]>(object: O, ...keys: K): Omit<O, typeof keys[number]> {
|
|
||||||
const cloned = { ...object };
|
|
||||||
keys.forEach((k) => delete cloned[k]);
|
|
||||||
return cloned;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async (unloads: any[]): Promise<VendettaObject> => ({
|
export default async (unloads: any[]): Promise<VendettaObject> => ({
|
||||||
patcher: without(patcher, "unpatchAll"),
|
patcher: utils.without(patcher, "unpatchAll"),
|
||||||
metro: { ...metro, common: { ...common } },
|
metro: { ...metro, common: { ...common } },
|
||||||
constants,
|
constants,
|
||||||
utils,
|
utils,
|
||||||
debug: without(debug, "versionHash", "patchLogHook"),
|
debug: utils.without(debug, "versionHash", "patchLogHook"),
|
||||||
ui: {
|
ui: {
|
||||||
components,
|
components,
|
||||||
toasts,
|
toasts,
|
||||||
|
@ -36,9 +30,9 @@ export default async (unloads: any[]): Promise<VendettaObject> => ({
|
||||||
assets,
|
assets,
|
||||||
...color,
|
...color,
|
||||||
},
|
},
|
||||||
plugins: without(plugins, "initPlugins", "evalPlugin"),
|
plugins: utils.without(plugins, "initPlugins", "evalPlugin"),
|
||||||
themes: without(themes, "initThemes"),
|
themes: utils.without(themes, "initThemes"),
|
||||||
commands: without(commands, "patchCommands"),
|
commands: utils.without(commands, "patchCommands"),
|
||||||
storage,
|
storage,
|
||||||
settings,
|
settings,
|
||||||
loader: {
|
loader: {
|
||||||
|
|
Loading…
Reference in a new issue