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

rokucommunity / brighterscript / #12841

24 Jul 2024 05:52PM UTC coverage: 87.936%. Remained the same
#12841

push

TwitchBronBron
0.67.4

6069 of 7376 branches covered (82.28%)

Branch coverage included in aggregate %.

8793 of 9525 relevant lines covered (92.31%)

1741.54 hits per line

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

52.0
/src/deferred.ts
1
export class Deferred<T = void, TReject = any> {
1✔
2
    constructor() {
3
        this._promise = new Promise<T>((resolve, reject) => {
154✔
4
            this._resolve = resolve;
154✔
5
            this._reject = reject;
154✔
6
        });
7
    }
8
    public get promise() {
9
        return this._promise;
154✔
10
    }
11
    private _promise: Promise<T>;
12

13
    /**
14
     * Indicates whether the promise has been resolved or rejected
15
     */
16
    public get isCompleted() {
17
        return this._isCompleted;
×
18
    }
19
    private _isCompleted = false;
154✔
20

21
    /**
22
     * Indicates whether the promise has been resolved
23
     */
24
    public get isResolved() {
25
        return this._isResolved;
×
26
    }
27
    private _isResolved = false;
154✔
28

29
    /**
30
     * Indicates whether the promise has been rejected
31
     */
32
    public get isRejected() {
33
        return this._isRejected;
×
34
    }
35
    private _isRejected = false;
154✔
36

37
    /**
38
     * Resolve the promise
39
     */
40
    public resolve(value?: T) {
41
        if (this._isCompleted) {
154!
42
            throw new Error('Already completed.');
×
43
        }
44
        this._isCompleted = true;
154✔
45
        this._isResolved = true;
154✔
46
        this._resolve(value);
154✔
47
    }
48
    private _resolve: (value: T) => void;
49

50
    /**
51
     * Reject the promise
52
     */
53
    public reject(value: TReject) {
54
        if (this._isCompleted) {
×
55
            throw new Error('Already completed.');
×
56
        }
57
        this._isCompleted = true;
×
58
        this._isRejected = true;
×
59
        this._reject(value);
×
60
    }
61
    private _reject: (value: TReject) => void;
62
}
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