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

rokucommunity / brighterscript / #13111

30 Sep 2024 04:35PM UTC coverage: 86.842% (-1.4%) from 88.193%
#13111

push

web-flow
Merge 25fc06528 into 3a2dc7282

11525 of 14034 branches covered (82.12%)

Branch coverage included in aggregate %.

6990 of 7581 new or added lines in 100 files covered. (92.2%)

83 existing lines in 18 files now uncovered.

12691 of 13851 relevant lines covered (91.63%)

29449.4 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,307✔
4
    ) { }
5

6
    /**
7
     * Has the data been loaded
8
     */
9
    public isValueLoaded = false;
2,307✔
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,291✔
18
            this.isValueLoaded = true;
2,284✔
19
            this.resolve();
2,284✔
20
        }
21
        return this.resolvedData;
2,291✔
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,285✔
36
            result = this.initialData;
28✔
37
        } else if (typeof this.initialData === 'string') {
2,257✔
38
            result = Buffer.from(this.initialData);
2,245✔
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,285✔
49
        delete this.initialData;
2,285✔
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