| 41 | } |
| 42 | |
| 43 | class JobGraph { |
| 44 | constructor(jobs) { |
| 45 | this.nodes = []; |
| 46 | this.graph = {}; |
| 47 | for (const job of jobs) { |
| 48 | this.addNode(job); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | addPrereq(job, prereq) { |
| 53 | const jobNode = this.getNode(job); |
| 54 | const prereqNode = this.getNode(prereq); |
| 55 | jobNode.prereqs.push(prereqNode); |
| 56 | } |
| 57 | |
| 58 | getNode(job) { |
| 59 | if (!this.graph.hasOwnProperty(job)) this.addNode(job); |
| 60 | return this.graph[job]; |
| 61 | } |
| 62 | |
| 63 | addNode(job) { |
| 64 | this.graph[job] = new JobNode(job); |
| 65 | this.nodes.push(this.graph[job]); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | class JobNode { |
| 70 | constructor(job) { |
nothing calls this directly
no outgoing calls
no test coverage detected