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

glideapps / glide-data-grid / 7333166280

26 Dec 2023 10:45PM UTC coverage: 90.585% (+4.2%) from 86.42%
7333166280

Pull #810

github

jassmith
5.99.9-charlie1
Pull Request #810: 6.0.0

2594 of 3246 branches covered (0.0%)

3363 of 3831 new or added lines in 62 files covered. (87.78%)

265 existing lines in 12 files now uncovered.

15759 of 17397 relevant lines covered (90.58%)

3076.99 hits per line

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

84.62
/packages/core/src/internal/data-grid/cell-set.ts
1
import { packColRowToNumber, unpackNumberToColRow, unpackRow } from "../../common/render-state-provider.js";
1✔
2
import type { Item, Rectangle } from "./data-grid-types.js";
1✔
3

1✔
4
export class CellSet {
1✔
5
    private readonly cells: Set<number>;
1✔
6

1✔
7
    constructor(items: Item[] = []) {
1✔
8
        this.cells = new Set<number>(items.map(x => packColRowToNumber(x[0], x[1])));
126✔
9
    }
126✔
10

1✔
11
    public add(cell: Item): void {
1✔
NEW
12
        this.cells.add(packColRowToNumber(cell[0], cell[1]));
×
NEW
13
    }
×
14

1✔
15
    public has(cell: Item | undefined): boolean {
1✔
16
        if (cell === undefined) return false;
11,234✔
17
        return this.cells.has(packColRowToNumber(cell[0], cell[1]));
11,206✔
18
    }
11,234✔
19

1✔
20
    public remove(cell: Item): void {
1✔
NEW
21
        this.cells.delete(packColRowToNumber(cell[0], cell[1]));
×
NEW
22
    }
×
23

1✔
24
    public clear(): void {
1✔
NEW
25
        this.cells.clear();
×
NEW
26
    }
×
27

1✔
28
    public get size(): number {
1✔
29
        return this.cells.size;
77✔
30
    }
77✔
31

1✔
32
    public hasHeader(): boolean {
1✔
33
        for (const cellNumber of this.cells) {
52✔
34
            const row = unpackRow(cellNumber);
1,130✔
35
            if (row < 0) return true;
1,130✔
36
        }
1,130✔
37
        return false;
27✔
38
    }
52✔
39

1✔
40
    public hasItemInRectangle(rect: Rectangle): boolean {
1✔
41
        for (let row = rect.y; row < rect.y + rect.height; row++) {
215✔
42
            for (let col = rect.x; col < rect.x + rect.width; col++) {
2,698✔
43
                if (this.cells.has(packColRowToNumber(col, row))) {
12,782✔
44
                    return true;
62✔
45
                }
62✔
46
            }
12,782✔
47
        }
2,636✔
48
        return false;
153✔
49
    }
215✔
50

1✔
51
    public hasItemInRegion(rect: readonly (Rectangle & { when?: boolean })[]): boolean {
1✔
52
        for (const r of rect) {
56✔
53
            if (this.hasItemInRectangle(r)) {
95✔
54
                return true;
52✔
55
            }
52✔
56
        }
95✔
57
        return false;
4✔
58
    }
56✔
59

1✔
60
    public *values(): IterableIterator<Item> {
1✔
NEW
61
        for (const cellNumber of this.cells) {
×
NEW
62
            yield unpackNumberToColRow(cellNumber);
×
NEW
63
        }
×
NEW
64
    }
×
65
}
1✔
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