-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Traversing the diagram seems quite complex.
As far as I can tell any two nodes are connected via:
(child) Node 1 -- (source) Out port -- link -- (target) In port -- (parent) Node 2
This is the code that I have for finding the child nodes connected via a port to a parent node:
/**
* Find children of a node
* @param {Node} node Parent node
* @param {string} portName Port connecting to children e.g. 'In'
* @returns {[Node]} List of Nodes
*/
const children = (node, portName) => {
const links = Object.values(node.getPort(portName).getLinks());
return links.map(link => link.getSourcePort().getNode());
};Links and Ports are both objects so to iterate over them you have to do something like Object.values or Object.entries each time
Is there some other/neater way of doing this?
magnafilix
