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

glideapps / glide-data-grid / 7162113717

11 Dec 2023 02:22AM UTC coverage: 90.687% (+4.3%) from 86.42%
7162113717

Pull #810

github

jassmith
5.99.9-beta3
Pull Request #810: 6.0.0

2542 of 3176 branches covered (0.0%)

2797 of 3202 new or added lines in 60 files covered. (87.35%)

268 existing lines in 12 files now uncovered.

15532 of 17127 relevant lines covered (90.69%)

3037.55 hits per line

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

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

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

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

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

1✔
16
    public has(cell: Item | undefined): boolean {
1✔
17
        if (cell === undefined) return false;
28,645✔
18
        return this.cells.has(packColRowToNumber(cell[0], cell[1]));
28,617✔
19
    }
28,645✔
20

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

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

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

1✔
33
    public filterToRegion(rectangles: readonly (Rectangle & { when?: boolean })[]): void {
1✔
34
        const filtered = rectangles.filter(x => x.when !== false);
56✔
35
        if (filtered.length === 0) return;
56!
36
        for (const cellNumber of this.cells) {
56✔
37
            const item = unpackNumberToColRow(cellNumber);
1,134✔
38

1,134✔
39
            const isInsideAnyRectangle = filtered.some(rect => itemIsInRect(item, rect));
1,134✔
40

1,134✔
41
            if (!isInsideAnyRectangle) {
1,134✔
42
                this.cells.delete(cellNumber);
708✔
43
            }
708✔
44
        }
1,134✔
45
    }
56✔
46

1✔
47
    public hasHeader(): boolean {
1✔
48
        for (const cellNumber of this.cells) {
56✔
49
            const row = unpackRow(cellNumber);
1,134✔
50
            if (row < 0) return true;
1,134✔
51
        }
1,134✔
52
        return false;
30✔
53
    }
56✔
54

1✔
55
    public hasItemInRectangle(rect: Rectangle): boolean {
1✔
56
        for (let row = rect.y; row < rect.y + rect.height; row++) {
223✔
57
            for (let col = rect.x; col < rect.x + rect.width; col++) {
223✔
58
                if (this.cells.has(packColRowToNumber(col, row))) {
830✔
59
                    return true;
15✔
60
                }
15✔
61
            }
830✔
62
        }
208✔
63
        return false;
208✔
64
    }
223✔
65

1✔
66
    public *values(): IterableIterator<Item> {
1✔
NEW
67
        for (const cellNumber of this.cells) {
×
NEW
68
            yield unpackNumberToColRow(cellNumber);
×
NEW
69
        }
×
NEW
70
    }
×
71
}
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