[nit] Move isColorable out of interfaces.ts (#564)

This commit is contained in:
Chenlei Hu
2025-02-23 13:06:03 -05:00
committed by GitHub
parent d17e7f567d
commit 86f823b7d5
3 changed files with 9 additions and 8 deletions

View File

@@ -83,13 +83,6 @@ export interface IColorable {
getColorOption(): ColorOption | null
}
/**
* 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
}
/**
* An object that can be pinned.
*

View File

@@ -22,7 +22,7 @@ import type {
ColorOption,
IColorable,
} from "./interfaces"
import { isColorable } 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"

8
src/typeGuards.ts Normal file
View File

@@ -0,0 +1,8 @@
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
}