# Module: Node

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

Source:
  - node.js, line 1

### Methods

#### (static) component(node) → {string}

Returns the componentId of the node.

##### Parameters:

Name | Type | Description
--- | --- | ---
`node` | Node | The node.

Source:
  - node.js, line 326

##### 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:
  - node.js, line 23

##### 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:
  - node.js, line 109

##### 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:
  - node.js, line 100

##### 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:
  - node.js, line 82

##### 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:
  - node.js, line 91

##### 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:
  - node.js, line 49

##### 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:
  - node.js, line 185

##### 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:
  - node.js, line 355

##### 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:
  - node.js, line 39

##### 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:
  - node.js, line 317

##### 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:
  - node.js, line 364

##### 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:
  - node.js, line 65

##### 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:
  - node.js, line 172

##### 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:
  - node.js, line 261

##### 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:
  - node.js, line 153

##### 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:
  - node.js, line 113

##### 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:
  - node.js, line 341

##### 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 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:
  - node.js, line 281

##### 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 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:
  - node.js, line 296

##### 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 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:
  - node.js, line 266

##### 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:
  - node.js, line 214

##### 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:
  - node.js, line 235

##### 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:
  - node.js, line 193

##### 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:
  - node.js, line 330

##### Returns:

A new node that has the new properties applied.

Type
  Node