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

rokucommunity / brighterscript / #12717

14 Jun 2024 08:20PM UTC coverage: 85.629% (-2.3%) from 87.936%
#12717

push

web-flow
Merge 94311dc0a into 42db50190

10808 of 13500 branches covered (80.06%)

Branch coverage included in aggregate %.

6557 of 7163 new or added lines in 96 files covered. (91.54%)

83 existing lines in 17 files now uncovered.

12270 of 13451 relevant lines covered (91.22%)

26531.66 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,219✔
4
    ) { }
5

6
    /**
7
     * Has the data been loaded
8
     */
9
    public isValueLoaded = false;
2,219✔
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,206✔
18
            this.isValueLoaded = true;
2,199✔
19
            this.resolve();
2,199✔
20
        }
21
        return this.resolvedData;
2,206✔
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,200✔
36
            result = this.initialData;
28✔
37
        } else if (typeof this.initialData === 'string') {
2,172✔
38
            result = Buffer.from(this.initialData);
2,161✔
39
        } else if (typeof this.initialData === 'function') {
11!
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)) {
11!
46
            result = this.initialData.value;
11✔
47
        }
48
        this.resolvedData = result;
2,200✔
49
        delete this.initialData;
2,200✔
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';
11!
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