Add model and add event listeners

This commit is contained in:
Misode
2020-05-25 03:37:39 +02:00
parent 92161c39f1
commit 1bef36a713
8 changed files with 128 additions and 33 deletions

26
src/model/Path.ts Normal file
View File

@@ -0,0 +1,26 @@
type PathElement = (string | number)
export class Path {
private arr: PathElement[]
constructor(arr?: PathElement[]) {
this.arr = arr || []
}
last(): PathElement {
return this.arr[this.arr.length - 1]
}
pop(): Path {
return new Path(this.arr.slice(0, -1))
}
push(element: PathElement): Path {
return new Path([...this.arr, element])
}
copy(): Path {
return new Path([...this.arr])
}
}