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

FontoXML / fontoxpath / 4161802573

pending completion
4161802573

push

github

GitHub
Implement circular dependencies and partial modules

4894 of 5691 branches covered (86.0%)

Branch coverage included in aggregate %.

10517 of 11154 relevant lines covered (94.29%)

32506.8 hits per line

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

47.92
/src/expressions/dataTypes/Sequences/ArrayBackedSequence.ts
1
import { errFORG0006 } from '../../functions/FunctionOperationErrors';
3✔
2
import { DONE_TOKEN, IIterator, ready } from '../../util/iterators';
3✔
3
import ISequence, { SwitchCasesCases } from '../ISequence';
4
import isSubtypeOf from '../isSubtypeOf';
3✔
5
import sequenceFactory from '../sequenceFactory';
6
import Value, { ValueType } from '../Value';
7

8
export default class ArrayBackedSequence implements ISequence {
3✔
9
        public value: IIterator<Value>;
10

11
        constructor(
12
                private readonly _sequenceFactory: typeof sequenceFactory,
18,038✔
13
                private readonly _values: Value[]
18,038✔
14
        ) {
15
                let i = -1;
18,038✔
16
                this.value = {
18,038✔
17
                        next: () => {
18
                                i++;
65,472✔
19
                                if (i >= _values.length) {
65,472✔
20
                                        return DONE_TOKEN;
17,820✔
21
                                }
22
                                return ready(_values[i]);
47,652✔
23
                        },
24
                };
25
        }
26

27
        public expandSequence(): ISequence {
28
                return this;
×
29
        }
30

31
        public filter(callback: (value: Value, i: number, sequence: ISequence) => boolean): ISequence {
32
                let i = -1;
×
33
                return this._sequenceFactory.create({
×
34
                        next: () => {
35
                                i++;
×
36
                                while (i < this._values.length && !callback(this._values[i], i, this)) {
×
37
                                        i++;
×
38
                                }
39

40
                                if (i >= this._values.length) {
×
41
                                        return DONE_TOKEN;
×
42
                                }
43

44
                                return ready(this._values[i]);
×
45
                        },
46
                });
47
        }
48

49
        public first(): Value | null {
50
                return this._values[0];
6✔
51
        }
52

53
        public getAllValues(): Value[] {
54
                return this._values;
3✔
55
        }
56

57
        public getEffectiveBooleanValue(): boolean {
58
                if (isSubtypeOf(this._values[0].type, ValueType.NODE)) {
×
59
                        return true;
×
60
                }
61
                // We always have a length > 1, or we'd be a singletonSequence
62
                throw errFORG0006(
×
63
                        `Cannot determine the effective boolean value of a sequence with a length higher than one.`
64
                );
65
        }
66

67
        public getLength(): number {
68
                return this._values.length;
5✔
69
        }
70

71
        public isEmpty(): boolean {
72
                return false;
2✔
73
        }
74

75
        public isSingleton(): boolean {
76
                return false;
2✔
77
        }
78

79
        public map(callback: (value: Value, i: number, sequence: ISequence) => Value): ISequence {
80
                let i = -1;
127✔
81
                return this._sequenceFactory.create(
127✔
82
                        {
83
                                next: () => {
84
                                        return ++i >= this._values.length
487!
85
                                                ? DONE_TOKEN
86
                                                : ready(callback(this._values[i], i, this));
87
                                },
88
                        },
89
                        this._values.length
90
                );
91
        }
92

93
        public mapAll(callback: (allValues: Value[]) => ISequence): ISequence {
94
                return callback(this._values);
×
95
        }
96

97
        public switchCases(cases: SwitchCasesCases): ISequence {
98
                if (cases.multiple) {
×
99
                        return cases.multiple(this);
×
100
                }
101
                return cases.default(this);
×
102
        }
103
}
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

© 2025 Coveralls, Inc