Accessible via require('@buggyorg/graphtools').Port
Methods for handling ports. A port is attached to a node and connects data sources with sinks. The port format is a unique identifier for the port and its node unlike the port name.
Methods
(static) assertValid(port)
Asserts that the given port is valid.
Parameters:
Name | Type | Description |
---|---|---|
port |
The object to test. |
Throws:
-
Error if the object is not a valid port.
- Type
- Error
(static) isInputPort(port) → {boolean}
Returns whether the given port is an input port or not
Parameters:
Name | Type | Description |
---|---|---|
port |
Port | The port to check |
Returns:
True if the port is an input port, false otherwise.
- Type
- boolean
(static) isOutputPort(port) → {boolean}
Returns whether the given port is an output port or not
Parameters:
Name | Type | Description |
---|---|---|
port |
Port | The port to check |
Returns:
True if the port is an output port, false otherwise.
- Type
- boolean
(static) isPort() → {boolean}
Returns whether the given object is a port object or not.
Returns:
True if the value is a port, false otherwise.
- Type
- boolean
(static) isPortNotation() → {boolean}
Checks whether a string represents a port notation. A port notation is a string that
contains the information about the node and the port separated by an @
, e.g. 'nodeA@portB'
Returns:
True if the string represents a port notation, false otherwise.
- Type
- boolean
(static) isValid(port) → {boolean}
Returns whether the given port is valid or not.
Parameters:
Name | Type | Description |
---|---|---|
port |
The object to test. |
Returns:
True if the value is a valid port, false otherwise.
- Type
- boolean
(static) kind(port)
Returns the kind of the port. Either output or input.
Parameters:
Name | Type | Description |
---|---|---|
port |
Port | The port |
Returns:
The kind of the port. It is either 'input' or 'output'.
(static) node(port) → {NodeID}
Returns the node stored in the port
Parameters:
Name | Type | Description |
---|---|---|
port |
Port | The port in any form. |
Returns:
The node of the port.
- Type
- NodeID
(static) normalize(port) → {Port}
Returns a normalized port object in the form {node: <node-id>, port: <port-name>}
Parameters:
Name | Type | Description |
---|---|---|
port |
The port object in any digestable form. |
Returns:
A port object.
- Type
- Port
(static) portName(port) → {string}
Returns the port name stored for the port.
Parameters:
Name | Type | Description |
---|---|---|
port |
Port | The port in any form. |
Returns:
The name of the port.
- Type
- string
(static) setType(type, port)
Sets the type of a port and returns a new port with this updated port.
Parameters:
Name | Type | Description |
---|---|---|
type |
The type to set. |
|
port |
Port | The port |
Returns:
The updated port.
(static) toString() → {string}
Returns a string representation of the port
Returns:
A string representation of the port.
- Type
- string
(static) type(port)
Returns the data type of the port.
Parameters:
Name | Type | Description |
---|---|---|
port |
Port | The port |
Returns:
The type of the port.
(inner) create(node, port, kind) → {Port}
Create a new port object.
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | String | A node object or the id of a valid node. |
port |
String | The name of the port |
kind |
String | 'input' or 'output' |
Returns:
A valid port object.
- Type
- Port
(inner) equal(port1, port2) → {boolean}
Determines if two ports are equal
Parameters:
Name | Type | Description |
---|---|---|
port1 |
Port | One of the ports. |
port2 |
Port | The other port.. |
Returns:
True if the ports are equal, false otherwise.
- Type
- boolean
(inner) port(node, port) → {Port}
Create a proto port object that can be used as a location. It is no valid port.
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | String | A node object or the id of a valid node. |
port |
String | The name of the port |
Returns:
A valid port object.
- Type
- Port