blob: 59e4882f0d6236314f4f43768367931608532bfe [file] [log] [blame]
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +01001export default class GapModel {
2 constructor(data) {
3 this.data = data ?? {};
4 }
5
6 getCount() {
7 const a = this.data[1] ?? null;
8 return a != null ? a : 0;
9 }
10
11 setCount(value) {
12 this.data[1] = Number(value);
13 }
14
15 getStartMicroseconds() {
16 return this.data[2] ?? null;
17 }
18
19 setStartMicroseconds(value) {
20 this.data[2] = '' + value;
21 }
22
23 getStartTimestamp() {
Adrià Vilanova Martínez412b7582022-12-30 01:35:30 +010024 let a = this.getStartMicroseconds();
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +010025 if (a == null) a = '0';
26 return BigInt(a);
27 }
28
29 getEndMicroseconds() {
30 return this.data[3] ?? null;
31 }
32
33 setEndMicroseconds(value) {
34 this.data[3] = '' + value;
35 }
36
37 getEndTimestamp() {
Adrià Vilanova Martínez412b7582022-12-30 01:35:30 +010038 let a = this.getEndMicroseconds();
Adrià Vilanova Martínez2d9be8d2022-12-28 00:50:14 +010039 if (a == null) a = '0';
40 return BigInt(a);
41 }
42
43 getParentId() {
44 const a = this.data[4];
45 return a ? Number(a) : 0;
46 }
47
48 setParentId(value) {
49 this.data[4] = '' + value;
50 }
51
52 toRawMessageOrGap() {
53 return {2: this.data};
54 }
55}