Remove entry point import, merge modules (#590)

* Remove unused import in lib entry point

* [Refactor] Merge type util modules
This commit is contained in:
filtered
2025-02-25 12:25:42 +11:00
committed by GitHub
parent ad8dd7a9d8
commit a4b9704a80
3 changed files with 10 additions and 10 deletions

View File

@@ -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 }

View File

@@ -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
}

View File

@@ -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<P, C>(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
}