Adrià Vilanova Martínez | 2d9be8d | 2022-12-28 00:50:14 +0100 | [diff] [blame] | 1 | export 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ínez | 412b758 | 2022-12-30 01:35:30 +0100 | [diff] [blame] | 24 | let a = this.getStartMicroseconds(); |
Adrià Vilanova Martínez | 2d9be8d | 2022-12-28 00:50:14 +0100 | [diff] [blame] | 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() { |
Adrià Vilanova Martínez | 412b758 | 2022-12-30 01:35:30 +0100 | [diff] [blame] | 38 | let a = this.getEndMicroseconds(); |
Adrià Vilanova Martínez | 2d9be8d | 2022-12-28 00:50:14 +0100 | [diff] [blame] | 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 | } |