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

keplergl / kepler.gl / 12482165950

24 Dec 2024 01:12PM UTC coverage: 67.451% (-0.1%) from 67.586%
12482165950

push

github

web-flow
[chore] 3.1.0-alpha.2 release (#2855)

- bump version for release
- temporarily disable vector tile layer plumbing
- ts fixes required for npm-publish
- prepublish to prepublishOnly script

5810 of 10000 branches covered (58.1%)

Branch coverage included in aggregate %.

4 of 9 new or added lines in 7 files covered. (44.44%)

29 existing lines in 4 files now uncovered.

11954 of 16336 relevant lines covered (73.18%)

86.83 hits per line

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

0.0
/src/layers/src/vector-tile/common-tile/iterable-tile-set.ts
1
// SPDX-License-Identifier: MIT
2
// Copyright contributors to the kepler.gl project
3

4
/**
5
 * Custom iterator for data in a set of tiles
6
 */
7
class TileSetIterator<T extends Iterable<any>> {
8
  private tileIterator: Iterator<T extends Iterable<infer V> ? V : never> | null = null;
×
9
  private tileIndex = -1;
×
10

11
  constructor(private readonly tiles: readonly T[]) {}
12

13
  nextTile() {
14
    if (this.tileIndex < this.tiles.length - 1) {
×
15
      this.tileIndex++;
×
16
      this.tileIterator = this.tiles[this.tileIndex][Symbol.iterator]();
×
17
    } else {
18
      this.tileIterator = null;
×
19
    }
20
  }
21

22
  next(): IteratorResult<T extends Iterable<infer V> ? V : never> {
23
    // Startup: Get the iterator for the next tile
24
    if (this.tileIterator === null) this.nextTile();
×
25
    // Finish: We have no more tiles, we're done
26
    if (this.tileIterator === null) return {done: true, value: null};
×
27

28
    const next = this.tileIterator.next();
×
29
    // If we have a value for the current tile, return it
30
    if (!next.done) {
×
31
      return next;
×
32
    }
33

34
    // Otherwise, go on to the next tile
35
    this.tileIterator = null;
×
36
    return this.next();
×
37
  }
38

39
  [Symbol.iterator]() {
40
    return this;
×
41
  }
42
}
43

44
export type RowCountAccessor<T> = (tile: T) => number;
45

46
/**
47
 * An iterable object that can iterate over all rows
48
 * in a set of tiles, treat the set as a single iterable
49
 */
50
export default class IterableTileSet<T extends Iterable<any>> {
UNCOV
51
  rowCount = 0;
×
UNCOV
52
  private rowCounts: number[] = [];
×
53

54
  constructor(private readonly tiles: readonly T[], getRowCount: RowCountAccessor<T>) {
UNCOV
55
    for (const tile of tiles) {
×
56
      const count = getRowCount(tile);
×
57
      this.rowCount += count;
×
58
      this.rowCounts.push(count);
×
59
    }
60
  }
61

62
  /**
63
   * Iterate over all values in the set
64
   */
65
  [Symbol.iterator](): Iterator<T extends Iterable<infer V> ? V : never> {
66
    return new TileSetIterator<T>(this.tiles);
×
67
  }
68
}
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