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

glideapps / glide-data-grid / 7244578514

18 Dec 2023 06:42AM UTC coverage: 90.724% (+4.3%) from 86.42%
7244578514

Pull #810

github

jassmith
5.99.9-beta7
Pull Request #810: 6.0.0

2552 of 3197 branches covered (0.0%)

3002 of 3411 new or added lines in 61 files covered. (88.01%)

265 existing lines in 12 files now uncovered.

15581 of 17174 relevant lines covered (90.72%)

2978.07 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])));
132✔
9
    }
132✔
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;
10,893✔
17
        return this.cells.has(packColRowToNumber(cell[0], cell[1]));
10,865✔
18
    }
10,893✔
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;
75✔
30
    }
75✔
31

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

1✔
40
    public hasItemInRectangle(rect: Rectangle): boolean {
1✔
41
        for (let row = rect.y; row < rect.y + rect.height; row++) {
213✔
42
            for (let col = rect.x; col < rect.x + rect.width; col++) {
2,695✔
43
                if (this.cells.has(packColRowToNumber(col, row))) {
12,760✔
44
                    return true;
61✔
45
                }
61✔
46
            }
12,760✔
47
        }
2,634✔
48
        return false;
152✔
49
    }
213✔
50

1✔
51
    public hasItemInRegion(rect: readonly (Rectangle & { when?: boolean })[]): boolean {
1✔
52
        for (const r of rect) {
55✔
53
            if (this.hasItemInRectangle(r)) {
94✔
54
                return true;
51✔
55
            }
51✔
56
        }
94✔
57
        return false;
4✔
58
    }
55✔
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