init
This commit is contained in:
		
							
								
								
									
										17
									
								
								lib/.eslintrc.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								lib/.eslintrc.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| module.exports = { | ||||
|   env: { | ||||
|     commonjs: true, | ||||
|     es6: true, | ||||
|     node: true | ||||
|   }, | ||||
|   extends: [ | ||||
|     '@scode/eslint-config-ts' | ||||
|   ], | ||||
|   globals: { | ||||
|     Atomics: 'readonly', | ||||
|     SharedArrayBuffer: 'readonly' | ||||
|   }, | ||||
|   parserOptions: { | ||||
|     ecmaVersion: 2018 | ||||
|   } | ||||
| } | ||||
							
								
								
									
										9
									
								
								lib/Edge.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								lib/Edge.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| export class Edge { | ||||
|   public origin: string; | ||||
|   public target: string; | ||||
|  | ||||
|   // eslint-disable-next-line @typescript-eslint/naming-convention | ||||
|   public toString (): string { | ||||
|     return `${this.origin} -> ${this.target}`; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										23
									
								
								lib/Graph.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								lib/Graph.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| import { Node } from './Node'; | ||||
| import { Edge } from './Edge'; | ||||
|  | ||||
| export class Graph extends Node { | ||||
|   public children: Array<Graph> = []; | ||||
|   public nodes: Array<GraphNode> = []; | ||||
|   public is_root = false; | ||||
|   public edges: Array<Edge>; | ||||
|  | ||||
|   // eslint-disable-next-line @typescript-eslint/naming-convention | ||||
|   public toString (): string { | ||||
|     return `subgraph cluster_${this.full_name} {  | ||||
|   ${this.children.map ((c) => c.toString ()) | ||||
|     .join ('\n')} | ||||
|    | ||||
|   ${this.nodes.map ((c) => c.toString ()) | ||||
|     .join ('\n')} | ||||
|  | ||||
|   ${this.edges.map ((c) => c.toString ()) | ||||
|     .join ('\n')} | ||||
| }`; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										20
									
								
								lib/GraphNode.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								lib/GraphNode.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| import { Node } from './Node'; | ||||
|  | ||||
| export class GraphNode extends Node { | ||||
|   public label: string; | ||||
|   public is_table: boolean; | ||||
|   public table_contents: Array<Array<string>>; | ||||
|  | ||||
|   private get serialized_table (): string { | ||||
|     const mapped_columns = this.table_contents | ||||
|       .map ((val) => `<td>${val.join ('</td><td>')}</td>`); | ||||
|     return `<table><tr>${mapped_columns.join ('</tr><tr>')}</tr></table>`; | ||||
|   } | ||||
|  | ||||
|   // eslint-disable-next-line @typescript-eslint/naming-convention | ||||
|   public toString (): string { | ||||
|     return `${this.full_name}[label=<${this.is_table | ||||
|       ? this._serialized_table | ||||
|       : this.label}>]`; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										12
									
								
								lib/Node.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								lib/Node.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| export class Node { | ||||
|   public name; | ||||
|   public parent; | ||||
|   public get full_name (): string { | ||||
|     return `${this.parent}_${this.name}`; | ||||
|   } | ||||
|  | ||||
|   // eslint-disable-next-line @typescript-eslint/naming-convention | ||||
|   public toString (): string { | ||||
|     return this.full_name; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										4
									
								
								lib/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								lib/index.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | ||||
| export { Graph } from './Graph'; | ||||
| export { GraphNode } from './GraphNode'; | ||||
| export { Node } from './Node'; | ||||
| export { Edge } from './Edge'; | ||||
		Reference in New Issue
	
	Block a user