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

visgl / loaders.gl / 24153816851

08 Apr 2026 07:17PM UTC coverage: 53.247% (-12.1%) from 65.319%
24153816851

push

github

web-flow
chore: Move from tape to vitest (#3351)

8651 of 17291 branches covered (50.03%)

Branch coverage included in aggregate %.

7 of 7 new or added lines in 1 file covered. (100.0%)

2031 existing lines in 296 files now uncovered.

17563 of 31940 relevant lines covered (54.99%)

5279.54 hits per line

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

43.24
/modules/gis/src/lib/utils/binary-reader.ts
1
// loaders.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
/** A DataView that tracks byte offset when reading. */
6
export class BinaryReader {
7
  arrayBuffer: ArrayBuffer;
8
  dataView: DataView;
9
  byteOffset: number;
10
  littleEndian: boolean;
11

12
  constructor(arrayBuffer: ArrayBuffer, isBigEndian: boolean = false) {
48✔
13
    this.arrayBuffer = arrayBuffer;
48✔
14
    this.dataView = new DataView(arrayBuffer);
48✔
15
    this.byteOffset = 0;
48✔
16
    this.littleEndian = !isBigEndian;
48✔
17
  }
18

19
  readUInt8() {
20
    const value = this.dataView.getUint8(this.byteOffset);
112✔
21
    this.byteOffset += 1;
112✔
22
    return value;
112✔
23
  }
24
  readUInt16() {
25
    const value = this.dataView.getUint16(this.byteOffset, this.littleEndian);
×
26
    this.byteOffset += 2;
×
27
    return value;
×
28
  }
29
  readUInt32() {
30
    const value = this.dataView.getUint32(this.byteOffset, this.littleEndian);
×
31
    this.byteOffset += 4;
×
32
    return value;
×
33
  }
34
  readInt8() {
35
    const value = this.dataView.getInt8(this.byteOffset);
×
36
    this.byteOffset += 1;
×
37
    return value;
×
38
  }
39
  readInt16() {
40
    const value = this.dataView.getInt16(this.byteOffset, this.littleEndian);
×
41
    this.byteOffset += 2;
×
42
    return value;
×
43
  }
44
  readInt32() {
45
    const value = this.dataView.getInt32(this.byteOffset, this.littleEndian);
×
46
    this.byteOffset += 4;
×
47
    return value;
×
48
  }
49
  readFloat() {
50
    const value = this.dataView.getFloat32(this.byteOffset, this.littleEndian);
×
UNCOV
51
    this.byteOffset += 4;
×
UNCOV
52
    return value;
×
53
  }
54
  readDouble() {
55
    const value = this.dataView.getFloat64(this.byteOffset, this.littleEndian);
×
56
    this.byteOffset += 8;
×
57
    return value;
×
58
  }
59

60
  readVarInt() {
61
    let result = 0;
473✔
62
    let bytesRead = 0;
473✔
63

64
    let nextByte;
65
    do {
473✔
66
      // TODO - this needs to be accessed via data view?
67
      nextByte = this.dataView.getUint8(this.byteOffset + bytesRead);
1,133✔
68
      result += (nextByte & 0x7f) << (7 * bytesRead);
1,133✔
69
      bytesRead++;
1,133✔
70
    } while (nextByte >= 0x80);
71

72
    this.byteOffset += bytesRead;
473✔
73

74
    return result;
473✔
75
  }
76
}
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