blob: 131dfbc192ae47c97dee7dbde794bb111c2311f2 [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() {
24 const a = this.getStartMicroseconds();
25 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() {
38 const a = this.getEndMicroseconds();
39 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}