mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-07 22:20:03 +00:00
[API] Add reroute convenience methods (#812)
Adds `LGraph.getReroute`, which accepts null & undefined IDs. Interface overloads result in `never` when given a _known_ `undefined` or `null` value.
This commit is contained in:
@@ -1398,6 +1398,17 @@ export class LGraph implements LinkNetwork, Serialisable<SerialisableGraph> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reroute by ID, or `undefined` if the ID is `null` or `undefined`.
|
||||
* @param id ID of reroute to return
|
||||
* @returns The reroute with the provided {@link id}, otherwise `undefined`. Always returns `undefined` if `id` is `null` or `undefined`.
|
||||
*/
|
||||
getReroute(id: null | undefined): undefined
|
||||
getReroute(id: RerouteId | null | undefined): Reroute | undefined
|
||||
getReroute(id: RerouteId | null | undefined): Reroute | undefined {
|
||||
return id == null ? undefined : this.reroutes.get(id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a reroute on the graph where ID is already known (probably deserialisation).
|
||||
* Creates the object if it does not exist.
|
||||
|
||||
Reference in New Issue
Block a user