mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-02 22:37:32 +00:00
- Returns object with slot, index, and pos - Locate-by-type returns object with slot & index - Uses standard `undefined` return for concise chaining & validation - Free 10x perf increase over getConnectionPos (used basic random data to test, out of curiosity)
24 lines
793 B
TypeScript
24 lines
793 B
TypeScript
import type { ISlotType } from "./litegraph"
|
|
|
|
/**
|
|
* Uses the standard String() function to coerce to string, unless the value is null or undefined - then null.
|
|
* @param value The value to convert
|
|
* @returns String(value) or null
|
|
*/
|
|
export function stringOrNull(value: unknown): string | null {
|
|
return value == null ? null : String(value)
|
|
}
|
|
|
|
/**
|
|
* Uses the standard String() function to coerce to string, unless the value is null or undefined - then an empty string
|
|
* @param value The value to convert
|
|
* @returns String(value) or ""
|
|
*/
|
|
export function stringOrEmpty(value: unknown): string {
|
|
return value == null ? "" : String(value)
|
|
}
|
|
|
|
export function parseSlotTypes(type: ISlotType): string[] {
|
|
return type == "" || type == "0" ? ["*"] : String(type).toLowerCase().split(",")
|
|
}
|