mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 17:10:07 +00:00
Implement BooleanWidget (#466)
* Implement BooleanWidget * Merge function of addWidget * Class conversion * nit
This commit is contained in:
9
src/utils/type.ts
Normal file
9
src/utils/type.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* 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
|
||||
* @param obj The object to convert
|
||||
* @returns The class instance
|
||||
*/
|
||||
export function toClass<P, C>(cls: new (plain: P) => C, obj: P | C): C {
|
||||
return obj instanceof cls ? obj : new cls(obj as P)
|
||||
}
|
||||
Reference in New Issue
Block a user