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

rokucommunity / brs / #65

30 Mar 2024 09:38PM UTC coverage: 90.304% (-0.2%) from 90.458%
#65

push

web-flow
Merge 1645a123c into de423b48a

1848 of 2200 branches covered (84.0%)

Branch coverage included in aggregate %.

135 of 150 new or added lines in 10 files covered. (90.0%)

4 existing lines in 2 files now uncovered.

5491 of 5927 relevant lines covered (92.64%)

8675.89 hits per line

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

88.89
/src/brsTypes/components/BrsComponent.ts
1
import { BrsType } from "..";
2
import { BrsInvalid, ValueKind, BrsValue } from "../BrsType";
3
import { Callable } from "../Callable";
4
import { BrsInterface } from "../BrsInterface";
141✔
5

6
export class BrsComponent {
141✔
7
    private methods: Map<string, Callable> = new Map<string, Callable>();
15,472✔
8
    private readonly componentName: string;
9

10
    readonly interfaces = new Map<string, BrsInterface>();
15,472✔
11

12
    constructor(name: string) {
13
        this.componentName = name;
15,472✔
14
    }
15

16
    /**
17
     * Returns the name of the component, used to create instances via `createObject`.
18
     * @returns the name of this component.
19
     */
20
    getComponentName(): string {
21
        return this.componentName;
169✔
22
    }
23

24
    hasInterface(interfaceName: string) {
NEW
25
        return this.interfaces.has(interfaceName.toLowerCase());
×
26
    }
27

28
    protected registerMethods(interfaces: Record<string, Callable[]>) {
29
        Object.entries(interfaces).forEach(([interfaceName, methods]) => {
15,405✔
30
            let interfaceKey = interfaceName.toLowerCase();
41,076✔
31
            if (!this.interfaces.has(interfaceKey)) {
41,076✔
32
                this.interfaces.set(interfaceKey, new BrsInterface(interfaceName, methods));
41,016✔
33
            }
34

35
            this.appendMethods(methods);
41,076✔
36
        });
37
    }
38

39
    /** Appends a method to the component. */
40
    appendMethod(index: string, method: Callable) {
41
        this.methods.set(index.toLowerCase(), method);
6✔
42
    }
43

44
    /** Given a list of methods, appends all of them to the component. */
45
    appendMethods(methods: Callable[]) {
46
        methods.forEach((m) => this.methods.set((m.name || "").toLowerCase(), m));
269,852!
47
    }
48

49
    getMethod(index: string): Callable | undefined {
50
        return this.methods.get(index.toLowerCase());
1,965✔
51
    }
52
}
53

54
/** Represents a BrightScript component that has elements that can be iterated across. */
55
export interface BrsIterable {
56
    /**
57
     * Returns the set of iterable elements contained in this component.
58
     * @returns an array of elements contained in this component.
59
     */
60
    getElements(): ReadonlyArray<BrsType>;
61

62
    /**
63
     * Retrieves an element from this component at the provided `index`.
64
     * @param index the index in this component from which to retrieve the desired element.
65
     * @param isCaseSensitive determinate whether operation of getting should be case sensitive or not.
66
     * @returns the element at `index` if one exists, otherwise throws an Error.
67
     */
68
    get(index: BrsType, isCaseSensitive?: boolean): BrsType;
69

70
    set(index: BrsType, value: BrsType, isCaseSensitive?: boolean): BrsInvalid;
71
}
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