From a4b9704a803dadf681cb72d2d7f7b89b288985fe Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Tue, 25 Feb 2025 12:25:42 +1100 Subject: [PATCH] Remove entry point import, merge modules (#590) * Remove unused import in lib entry point * [Refactor] Merge type util modules --- src/litegraph.ts | 3 +-- src/typeGuards.ts | 8 -------- src/utils/type.ts | 9 +++++++++ 3 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 src/typeGuards.ts diff --git a/src/litegraph.ts b/src/litegraph.ts index 2a169ab2b..1e7bd3688 100644 --- a/src/litegraph.ts +++ b/src/litegraph.ts @@ -22,7 +22,6 @@ import type { ColorOption, IColorable, } from "./interfaces" -import { isColorable } from "./typeGuards" import type { SlotShape, LabelPosition, SlotDirection, SlotType } from "./draw" import type { IWidget } from "./types/widgets" import type { RenderShape, TitleMode } from "./types/globalEnums" @@ -75,8 +74,8 @@ export { Size, ColorOption, IColorable, - isColorable, } +export { isColorable } from "./utils/type" export { IWidget } export { LGraphBadge, BadgePosition } export { SlotShape, LabelPosition, SlotDirection, SlotType } diff --git a/src/typeGuards.ts b/src/typeGuards.ts deleted file mode 100644 index 3a1528555..000000000 --- a/src/typeGuards.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { IColorable } from "@/interfaces" - -/** - * Checks if an object is an instance of {@link IColorable}. - */ -export const isColorable = (obj: unknown): obj is IColorable => { - return typeof obj === "object" && obj !== null && "setColorOption" in obj && "getColorOption" in obj -} diff --git a/src/utils/type.ts b/src/utils/type.ts index b6dc33266..0b1be57b8 100644 --- a/src/utils/type.ts +++ b/src/utils/type.ts @@ -1,3 +1,5 @@ +import type { IColorable } from "@/interfaces" + /** * Converts a plain object to a class instance if it is not already an instance of the class. * @param cls The class to convert to @@ -7,3 +9,10 @@ export function toClass(cls: new (plain: P) => C, obj: P | C): C { return obj instanceof cls ? obj : new cls(obj as P) } + +/** + * Checks if an object is an instance of {@link IColorable}. + */ +export const isColorable = (obj: unknown): obj is IColorable => { + return typeof obj === "object" && obj !== null && "setColorOption" in obj && "getColorOption" in obj +}