|
1 |
| -"use strict"; |
2 |
| -const Node = require("../dist/node"), |
3 |
| - Edge = require("../dist/edge"), |
4 |
| - Path = require("../dist/path"); |
| 1 | +const { Node, Edge, Path } = require("../dist/index"); |
5 | 2 |
|
6 | 3 | class PathBuilder {
|
7 |
| - constructor(nodeCount) { |
8 |
| - this.nodes = new Array(); |
9 |
| - this.edges = new Array(); |
10 |
| - this.currentAppendClass = Node; |
11 |
| - } |
| 4 | + constructor(nodeCount) { |
| 5 | + this.nodes = new Array(); |
| 6 | + this.edges = new Array(); |
| 7 | + this.currentAppendClass = Node; |
| 8 | + } |
12 | 9 |
|
13 |
| - append(obj) { |
14 |
| - if (!obj instanceof this.currentAppendClass) |
15 |
| - throw "Error in path build insertion order and types."; |
16 |
| - if (obj instanceof Node) return this._appendNode(obj); |
17 |
| - else return this._appendEdge(obj); |
18 |
| - } |
| 10 | + append(obj) { |
| 11 | + if (!obj instanceof this.currentAppendClass) |
| 12 | + throw "Error in path build insertion order and types."; |
| 13 | + if (obj instanceof Node) return this._appendNode(obj); |
| 14 | + else return this._appendEdge(obj); |
| 15 | + } |
19 | 16 |
|
20 |
| - build() { |
21 |
| - return new Path(this.nodes, this.edges); |
22 |
| - } |
| 17 | + build() { |
| 18 | + return new Path(this.nodes, this.edges); |
| 19 | + } |
23 | 20 |
|
24 |
| - _appendNode(node) { |
25 |
| - this.nodes.push(node); |
26 |
| - this.currentAppendClass = Edge; |
27 |
| - return this; |
28 |
| - } |
| 21 | + _appendNode(node) { |
| 22 | + this.nodes.push(node); |
| 23 | + this.currentAppendClass = Edge; |
| 24 | + return this; |
| 25 | + } |
29 | 26 |
|
30 |
| - _appendEdge(edge) { |
31 |
| - this.edges.push(edge); |
32 |
| - this.currentAppendClass = Node; |
33 |
| - return this; |
34 |
| - } |
| 27 | + _appendEdge(edge) { |
| 28 | + this.edges.push(edge); |
| 29 | + this.currentAppendClass = Node; |
| 30 | + return this; |
| 31 | + } |
35 | 32 | }
|
36 | 33 |
|
37 | 34 | module.exports = PathBuilder;
|
0 commit comments