MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / getInputData

Method getInputData

src/LGraphNode.ts:994–1018  ·  view source on GitHub ↗

* Retrieves the input data (data traveling through the connection) from one slot * @param slot * @param force_update if set to true it will force the connected node of this slot to output data into this link * @returns data or if it is not connected returns undefined

(slot: number, force_update?: boolean)

Source from the content-addressed store, hash-verified

992 * @returns data or if it is not connected returns undefined
993 */
994 getInputData(slot: number, force_update?: boolean): unknown {
995 if (!this.inputs) return
996
997 if (slot >= this.inputs.length || this.inputs[slot].link == null) return
998 if (!this.graph) throw new NullGraphError()
999
1000 const link_id = this.inputs[slot].link
1001 const link = this.graph._links.get(link_id)
1002 // bug: weird case but it happens sometimes
1003 if (!link) return null
1004
1005 if (!force_update) return link.data
1006
1007 // special case: used to extract data from the incoming connection before the graph has been executed
1008 const node = this.graph.getNodeById(link.origin_id)
1009 if (!node) return link.data
1010
1011 if (node.updateOutputData) {
1012 node.updateOutputData(link.origin_slot)
1013 } else {
1014 node.onExecute?.()
1015 }
1016
1017 return link.data
1018 }
1019
1020 /**
1021 * Retrieves the input data type (in case this supports multiple input types)

Callers 1

getInputDataByNameMethod · 0.95

Calls 2

getMethod · 0.80
getNodeByIdMethod · 0.65

Tested by

no test coverage detected