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

rokucommunity / brighterscript / #14302

24 Apr 2025 06:12PM UTC coverage: 87.099% (-1.9%) from 89.017%
#14302

push

web-flow
Merge 9f25468b6 into a742ceae5

13489 of 16372 branches covered (82.39%)

Branch coverage included in aggregate %.

8031 of 8709 new or added lines in 103 files covered. (92.21%)

85 existing lines in 22 files now uncovered.

14462 of 15719 relevant lines covered (92.0%)

19990.85 hits per line

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

79.07
/src/files/LazyFileData.ts
1
export class LazyFileData {
1✔
2
    constructor(
3
        private initialData: FileData
2,689✔
4
    ) { }
5

6
    /**
7
     * Has the data been loaded
8
     */
9
    public isValueLoaded = false;
2,689✔
10

11
    /**
12
     * Once the data has been loaded, this is where it's stored
13
     */
14
    private resolvedData: Buffer;
15

16
    public get value(): Buffer {
17
        if (!this.isValueLoaded) {
2,661✔
18
            this.isValueLoaded = true;
2,654✔
19
            this.resolve();
2,654✔
20
        }
21
        return this.resolvedData;
2,661✔
22
    }
23

24
    public set value(value: FileData) {
25
        this.isValueLoaded = true;
1✔
26
        this.initialData = value;
1✔
27
        this.resolve();
1✔
28
    }
29

30
    /**
31
     * Resolve the initialData into the actual data
32
     */
33
    private resolve() {
34
        let result: any;
35
        if (Buffer.isBuffer(this.initialData)) {
2,655✔
36
            result = this.initialData;
74✔
37
        } else if (typeof this.initialData === 'string') {
2,581✔
38
            result = Buffer.from(this.initialData);
2,569✔
39
        } else if (typeof this.initialData === 'function') {
12!
NEW
40
            result = this.initialData();
×
41
            //convert result to buffer
NEW
42
            if (!Buffer.isBuffer(result)) {
×
NEW
43
                result = Buffer.from(result);
×
44
            }
45
        } else if (isLazyFileData(this.initialData)) {
12!
46
            result = this.initialData.value;
12✔
47
        }
48
        this.resolvedData = result;
2,655✔
49
        delete this.initialData;
2,655✔
50
    }
51
}
52

53
export type FileData = string | Buffer | (() => Buffer | string) | LazyFileData;
54

55
function isLazyFileData(item: any): item is LazyFileData {
56
    return item?.constructor?.name === 'LazyFileData';
12!
57
}
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

© 2026 Coveralls, Inc