# Module: Port

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.

Source:
  - port.js, line 1

### Methods

#### (static) assertValid(port)

Asserts that the given port is valid.

##### Parameters:

Name | Type | Description
--- | --- | ---
`port` |  | The object to test.

Source:
  - port.js, line 148

##### 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

Source:
  - port.js, line 120

##### 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

Source:
  - port.js, line 111

##### 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.

Source:
  - port.js, line 129

##### 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'

Source:
  - port.js, line 21

##### 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.

Source:
  - port.js, line 139

##### 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

Source:
  - port.js, line 102

##### 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.

Source:
  - port.js, line 65

##### 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.

Source:
  - port.js, line 42

##### 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.

Source:
  - port.js, line 74

##### 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

Source:
  - port.js, line 93

##### Returns:

The updated port.

#### (static) toString() → {string}

Returns a string representation of the port

Source:
  - port.js, line 168

##### 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

Source:
  - port.js, line 83

##### 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'

Source:
  - port.js, line 188

##### 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..

Source:
  - port.js, line 172

##### 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

Source:
  - port.js, line 205

##### Returns:

A valid port object.

Type
  Port