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

rokucommunity / brighterscript / #12930

13 Aug 2024 05:02PM UTC coverage: 86.193% (-1.7%) from 87.933%
#12930

push

web-flow
Merge 58ad447a2 into 0e968f1c3

10630 of 13125 branches covered (80.99%)

Branch coverage included in aggregate %.

6675 of 7284 new or added lines in 99 files covered. (91.64%)

84 existing lines in 18 files now uncovered.

12312 of 13492 relevant lines covered (91.25%)

26865.48 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,254✔
4
    ) { }
5

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