Module: Node

Accessible via require('@buggyorg/graphtools').Node

Source:

Methods

(static) component(node) → {string}

Returns the componentId of the node.

Parameters:
Name Type Description
node Node

The node.

Source:
Returns:

The componentId of the node.

Type
string

(static) create(node) → {Node}

Creates a normalized node object. It makes sure, that the node has all necessary information like an id and normalized ports.

Parameters:
Name Type Description
node Node

A protypical node object.

Source:
Returns:

A complete node object

Type
Node

(static) hasChildren(node) → {boolean}

Checks the node for children

Parameters:
Name Type Description
node Node

The node

Source:
Returns:

True if it has children, false otherwise.

Type
boolean

(static) hasID(node) → {boolean}

Checks the node for an id

Parameters:
Name Type Description
node Node

The node

Source:
Returns:

True if it has an id, false otherwise.

Type
boolean

(static) hasName(node) → {boolean}

Checks the node for a name

Parameters:
Name Type Description
node Node

The node

Source:
Returns:

True if it has a name, false otherwise.

Type
boolean

(static) hasPath(node) → {boolean}

Checks the node for a path

Parameters:
Name Type Description
node Node

The node

Source:
Returns:

True if it has a path, false otherwise.

Type
boolean

(static) id() → {string}

Returns the unique identifier of a node. The id is unique for the whole graph and cannot be assigned twice.

Source:
Throws:

If the node value is invalid.

Type
Error
Returns:

The unique identifier of the node

Type
string

(static) inputPorts(node) → {Array.<Port>}

Gets all input ports of the node.

Parameters:
Name Type Description
node Node

The node.

Source:
Returns:

A possibly empty list of input ports.

Type
Array.<Port>

(static) isAtomic(node) → {boolean}

Checks whether a node is an atomic node.

Parameters:
Name Type Description
node Node

The node.

Source:
Returns:

True if the node is an atomic node, false otherwise.

Type
boolean

(static) isID(obj) → {boolean}

Checks if the given object is an id.

Parameters:
Name Type Description
obj

The object to test

Source:
Returns:

True if the object is an id, false otherwise.

Type
boolean

(static) isReference(node) → {boolean}

Checks whether the node is a reference.

Parameters:
Name Type Description
node Node

The node.

Source:
Returns:

True if the node is a reference, false otherwise.

Type
boolean

(static) isValid(node) → {boolean}

Checks whether a node is in a valid format, i.e. if it has an id field and at least one port.

Parameters:
Name Type Description
node Node

The node to test.

Source:
Returns:

True if the node is valid, false otherwise.

Type
boolean

(static) name() → {string}

Gets the name of a node. The name is a unique identifier in respect to the parent. Each graph can have only one node with a specific name as its direct child. If a node has no name, the id is the name of the node.

Source:
Returns:

The name of the node.

Type
string

(static) outputPorts(node) → {Array.<Port>}

Gets all output ports of the node.

Parameters:
Name Type Description
node Node

The node.

Source:
Returns:

A possibly empty list of output ports.

Type
Array.<Port>

(static) path(node) → {CompoundPath}

Gets the path of a node

Parameters:
Name Type Description
node Node

The node

Source:
Returns:

The compound path of the node.

Type
CompoundPath

(static) ports(node) → {Array.<Port>}

Gets all ports of the node.

Parameters:
Name Type Description
node Node

The node.

Source:
Returns:

A list of ports.

Type
Array.<Port>

(inner) equal(node1, node2) → {boolean}

Tests whether two nodes are the same node. This tests only if their IDs are the same not if both nodes contain the same information.

Parameters:
Name Type Description
node1 Node

One of the nodes to test.

node2 Node

The other one.

Source:
Returns:

True if they have the same id, false otherwise.

Type
boolean

(inner) get(key)

Get a property for a node

Parameters:
Name Type Description
key String

The property key.

Source:
Returns:

The value of the property. If the property is not defined it will return undefined.

(inner) hasPort(name, node) → {Port}

Checks whether the node has the specific output port.

Parameters:
Name Type Description
name String | Port

The name of the port or a port object.

node Node

The node which has the port.

Source:
Returns:

True if the port has an output port with the given name, false otherwise.

Type
Port

(inner) hasPort(name, node) → {Port}

Checks whether the node has the specific input port.

Parameters:
Name Type Description
name String | Port

The name of the port or a port object.

node Node

The node which has the port.

Source:
Returns:

True if the port has an input port with the given name, false otherwise.

Type
Port

(inner) hasPort(name, node) → {Port}

Checks whether the node has the specific port.

Parameters:
Name Type Description
name String | Port

The name of the port or a port object.

node Node

The node which has the port.

Source:
Returns:

True if the port has a port with the given name, false otherwise.

Type
Port

(inner) inputPort(name, node) → {Port}

Returns the input port data for a given node and port name / index.

Parameters:
Name Type Description
name String | Port | Number

The name of the input port, a port object or the index.

node Node

The node which has the port.

Source:
Throws:

If no port with the given name exists in this node an error is thrown.

Type
Error
Returns:

The input port data.

Type
Port

(inner) outputPort(name, node) → {Port}

Returns the output port data for a given node and port name / index.

Parameters:
Name Type Description
name String | Port | Number

The name of the output port, a port object or the index.

node Node

The node which has the port.

Source:
Throws:

If no port with the given name exists in this node an error is thrown.

Type
Error
Returns:

The output port data.

Type
Port

(inner) port(name, node) → {Port}

Returns the port data for a given node and port.

Parameters:
Name Type Description
name String | Port

The name of the port or a port object.

node Node

The node which has the port.

Source:
Throws:

If no port with the given name exists in this node an error is thrown.

Type
Error
Returns:

The port data.

Type
Port

(inner) set(value) → {Node}

Set properties for the node

Parameters:
Name Type Description
value object

An object with keys and values that should be set for a node.

Source:
Returns:

A new node that has the new properties applied.

Type
Node