• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / roku-debug / #2026

02 Nov 2022 02:41PM UTC coverage: 56.194% (+7.0%) from 49.18%
#2026

push

TwitchBronBron
0.17.0

997 of 1898 branches covered (52.53%)

Branch coverage included in aggregate %.

2074 of 3567 relevant lines covered (58.14%)

15.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

8.0
/src/debugProtocol/responses/UpdateThreadsResponse.ts
1
import { SmartBuffer } from 'smart-buffer';
1✔
2
import { STOP_REASONS, UPDATE_TYPES } from '../Constants';
1✔
3
import { util } from '../../util';
1✔
4

5
export class UpdateThreadsResponse {
1✔
6

7
    constructor(buffer: Buffer) {
8
        if (buffer.byteLength >= 12) {
×
9
            try {
×
10
                let bufferReader = SmartBuffer.fromBuffer(buffer);
×
11
                this.requestId = bufferReader.readUInt32LE();
×
12
                if (this.requestId === 0) {
×
13
                    this.errorCode = bufferReader.readUInt32LE();
×
14
                    this.updateType = bufferReader.readUInt32LE();
×
15

16
                    let threadsUpdate: ThreadAttached | ThreadsStopped;
17
                    if (this.updateType === UPDATE_TYPES.ALL_THREADS_STOPPED) {
×
18
                        threadsUpdate = new ThreadsStopped(bufferReader);
×
19
                    } else if (this.updateType === UPDATE_TYPES.THREAD_ATTACHED) {
×
20
                        threadsUpdate = new ThreadAttached(bufferReader);
×
21
                    }
22

23
                    if (threadsUpdate?.success) {
×
24
                        this.data = threadsUpdate;
×
25
                        this.readOffset = bufferReader.readOffset;
×
26
                        this.success = true;
×
27
                    }
28
                }
29
            } catch (error) {
30
                // Can't be parsed
31
            }
32
        }
33
    }
34
    public success = false;
×
35
    public readOffset = 0;
×
36

37
    // response fields
38
    public requestId = -1;
×
39
    public errorCode = -1;
×
40
    public updateType = -1;
×
41
    public data: ThreadAttached | ThreadsStopped;
42
}
43

44
export class ThreadsStopped {
1✔
45

46
    constructor(bufferReader: SmartBuffer) {
47
        if (bufferReader.length >= bufferReader.readOffset + 6) {
×
48
            this.primaryThreadIndex = bufferReader.readInt32LE();
×
49
            this.stopReason = getStopReason(bufferReader.readUInt8());
×
50
            this.stopReasonDetail = util.readStringNT(bufferReader);
×
51
            this.success = true;
×
52
        }
53
    }
54
    public success = false;
×
55

56
    // response fields
57
    public primaryThreadIndex = -1;
×
58
    public stopReason = -1;
×
59
    public stopReasonDetail: string;
60
}
61

62
export class ThreadAttached {
1✔
63

64
    constructor(bufferReader: SmartBuffer) {
65
        if (bufferReader.length >= bufferReader.readOffset + 6) {
×
66
            this.threadIndex = bufferReader.readInt32LE();
×
67
            this.stopReason = getStopReason(bufferReader.readUInt8());
×
68
            this.stopReasonDetail = util.readStringNT(bufferReader);
×
69
            this.success = true;
×
70
        }
71
    }
72
    public success = false;
×
73

74
    // response fields
75
    public threadIndex = -1;
×
76
    public stopReason = -1;
×
77
    public stopReasonDetail: string;
78
}
79

80
function getStopReason(value: number): STOP_REASONS {
81
    switch (value) {
×
82
        case STOP_REASONS.BREAK:
83
            return STOP_REASONS.BREAK;
×
84
        case STOP_REASONS.NORMAL_EXIT:
85
            return STOP_REASONS.NORMAL_EXIT;
×
86
        case STOP_REASONS.NOT_STOPPED:
87
            return STOP_REASONS.NOT_STOPPED;
×
88
        case STOP_REASONS.RUNTIME_ERROR:
89
            return STOP_REASONS.RUNTIME_ERROR;
×
90
        case STOP_REASONS.STOP_STATEMENT:
91
            return STOP_REASONS.STOP_STATEMENT;
×
92
        case STOP_REASONS.UNDEFINED:
93
            return STOP_REASONS.UNDEFINED;
×
94
        default:
95
            return STOP_REASONS.UNDEFINED;
×
96
    }
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc