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

posthtml / posthtml-parser / 6637461812

25 Oct 2023 08:02AM UTC coverage: 99.301%. First build
6637461812

Pull #98

github

web-flow
Merge 18f39490c into 0db4129ec
Pull Request #98: Milestone 0.12.0

54 of 55 branches covered (0.0%)

29 of 29 new or added lines in 2 files covered. (100.0%)

284 of 286 relevant lines covered (99.3%)

42.79 hits per line

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

95.74
/src/location-tracker.ts
1
export type SourceLocation = {
3✔
2
  start: Position;
3✔
3
  end: Position;
3✔
4
};
3✔
5

3✔
6
export type Position = {
3✔
7
  line: number;
3✔
8
  column: number;
3✔
9
};
3✔
10

3✔
11
export class LocationTracker {
3✔
12
  private readonly source: string;
59✔
13
  private lastPosition: Position;
87✔
14
  private lastIndex: number;
87✔
15

59✔
16
  constructor(source: string) {
59✔
17
    this.source = source;
87✔
18
    this.lastPosition = {
87✔
19
      line: 1,
87✔
20
      column: 1,
87✔
21
    };
87✔
22

87✔
23
    this.lastIndex = 0;
87✔
24
  }
87✔
25

59✔
26
  getPosition(index: number): Position {
59✔
27
    if (index < this.lastIndex) {
57!
28
      throw new Error("Source indices must be monotonic");
×
29
    }
×
30

57✔
31
    while (this.lastIndex < index) {
57✔
32
      if (this.source.charCodeAt(this.lastIndex) === /* \n */ 10) {
135✔
33
        this.lastPosition.line++;
6✔
34
        this.lastPosition.column = 1;
6✔
35
      } else {
135✔
36
        this.lastPosition.column++;
129✔
37
      }
129✔
38

135✔
39
      this.lastIndex++;
135✔
40
    }
135✔
41

57✔
42
    return {
57✔
43
      line: this.lastPosition.line,
57✔
44
      column: this.lastPosition.column,
57✔
45
    };
57✔
46
  }
57✔
47
}
59✔
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