[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;
|
||||
safeFetch: (input: RequestInfo | URL, options?: RequestInit) => Promise<Response>;
|
||||
unfreeze: (obj: object) => object;
|
||||
without: <O extends object, K extends readonly (keyof O)[]>(object: O, ...keys: K) => Omit<O, typeof keys[number]>;
|
||||
};
|
||||
debug: {
|
||||
connectToDebugger: (url: string) => void;
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
export { default as findInReactTree } from "@utils/findInReactTree";
|
||||
export { default as findInTree } from "@utils/findInTree";
|
||||
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 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> => ({
|
||||
patcher: without(patcher, "unpatchAll"),
|
||||
patcher: utils.without(patcher, "unpatchAll"),
|
||||
metro: { ...metro, common: { ...common } },
|
||||
constants,
|
||||
utils,
|
||||
debug: without(debug, "versionHash", "patchLogHook"),
|
||||
debug: utils.without(debug, "versionHash", "patchLogHook"),
|
||||
ui: {
|
||||
components,
|
||||
toasts,
|
||||
|
@ -36,9 +30,9 @@ export default async (unloads: any[]): Promise<VendettaObject> => ({
|
|||
assets,
|
||||
...color,
|
||||
},
|
||||
plugins: without(plugins, "initPlugins", "evalPlugin"),
|
||||
themes: without(themes, "initThemes"),
|
||||
commands: without(commands, "patchCommands"),
|
||||
plugins: utils.without(plugins, "initPlugins", "evalPlugin"),
|
||||
themes: utils.without(themes, "initThemes"),
|
||||
commands: utils.without(commands, "patchCommands"),
|
||||
storage,
|
||||
settings,
|
||||
loader: {
|
||||
|
|
Loading…
Reference in a new issue