Add electron

This commit is contained in:
Thomas Nordquist
2019-01-01 15:31:33 +01:00
parent 4e09ea3d30
commit b2badfd43f
37 changed files with 3900 additions and 2578 deletions

35
backend/src/Model/Edge.ts Normal file
View File

@@ -0,0 +1,35 @@
import { Hashable, TreeNode } from './'
const sha1 = require('sha1')
export class Edge implements Hashable {
public name: string
public node!: TreeNode
public source?: TreeNode | undefined
private cachedHash?: string
constructor(name: string) {
this.name = name
}
public edges() {
return this.node ? Object.values(this.node.edges) : []
}
public hash(): string {
if (!this.cachedHash) {
let previousHash = (this.source && this.source.sourceEdge) ? this.source.sourceEdge.hash() : ''
this.cachedHash = 'H' + sha1(previousHash + this.name)
}
return this.cachedHash
}
public firstEdge(): Edge {
if (this.source && this.source.sourceEdge) {
return this.source.sourceEdge.firstEdge()
} else {
return this
}
}
}