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

visgl / luma.gl / 25756190722

12 May 2026 07:06PM UTC coverage: 75.119% (+0.2%) from 74.932%
25756190722

push

github

web-flow
feat(arrow) Support RecordBatch stream to ArrowGPUTable (#2611)

5973 of 8932 branches covered (66.87%)

Branch coverage included in aggregate %.

271 of 333 new or added lines in 9 files covered. (81.38%)

3 existing lines in 2 files now uncovered.

13032 of 16368 relevant lines covered (79.62%)

831.06 hits per line

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

88.06
/modules/test-utils/src/null-device/resources/null-buffer.ts
1
// luma.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
import {Buffer, type BufferProps, type BufferMapCallback} from '@luma.gl/core';
6
import {type NullDevice} from '../null-device';
7

8
export class NullBuffer extends Buffer {
9
  device: NullDevice;
10
  readonly handle: 'null' | null = 'null';
102✔
11

12
  byteLength: number;
13
  private _storage: ArrayBuffer;
14

15
  constructor(device: NullDevice, props: BufferProps = {}) {
102✔
16
    super(device, props);
102✔
17
    this.device = device;
102✔
18

19
    const byteOffset = props.byteOffset || 0;
102✔
20
    const byteLength = props.byteLength ?? (props.data ? props.data.byteLength + byteOffset : 0);
102✔
21

22
    this.byteLength = byteLength;
102✔
23
    this._storage = new ArrayBuffer(byteLength);
102✔
24

25
    // If initial data is provided, copy it in
26
    if (props.data) {
102✔
27
      this.write(props.data, byteOffset);
36✔
28
    }
29

30
    this.trackAllocatedMemory(byteLength);
102✔
31
  }
32

33
  override destroy(): void {
34
    if (!this.destroyed) {
96✔
35
      super.destroy();
95✔
36
      this.trackDeallocatedMemory();
95✔
37
      // @ts-expect-error
38
      this.handle = null;
95✔
39
      // Clear internal storage
40
      this._storage = new ArrayBuffer(0);
95✔
41
    }
42
  }
43

44
  write(data: ArrayBufferLike | ArrayBufferView, byteOffset: number = 0): void {
92✔
45
    const source = ArrayBuffer.isView(data)
92!
46
      ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength)
47
      : new Uint8Array(data);
48

49
    if (byteOffset + source.byteLength > this.byteLength) {
92!
50
      throw new RangeError(`NullBuffer.write(): write would overflow buffer`);
×
51
    }
52

53
    const target = new Uint8Array(this._storage, byteOffset, source.byteLength);
92✔
54
    target.set(source);
92✔
55
    this.updateTimestamp = this.device.incrementTimestamp();
92✔
56
    this._setDebugData(data, byteOffset, source.byteLength);
92✔
57
  }
58

59
  copyToBuffer(
60
    destinationBuffer: Buffer,
61
    sourceOffset: number,
62
    destinationOffset: number,
63
    size: number
64
  ): void {
65
    if (sourceOffset + size > this.byteLength) {
22!
NEW
66
      throw new RangeError(`NullBuffer.copyToBuffer(): read would overflow source buffer`);
×
67
    }
68

69
    const source = new Uint8Array(this._storage, sourceOffset, size);
22✔
70
    destinationBuffer.write(source, destinationOffset);
22✔
71
  }
72

73
  async mapAndWriteAsync(
74
    callback: BufferMapCallback<void>,
75
    byteOffset = 0,
2✔
76
    byteLength = this.byteLength - byteOffset
2✔
77
  ): Promise<void> {
78
    const view = new Uint8Array(this._storage, byteOffset, byteLength);
2✔
79
    const tempBuffer = new Uint8Array(view.length); // safe scratch copy
2✔
80
    callback(tempBuffer.buffer, 'copied');
2✔
81
    view.set(tempBuffer);
2✔
82
    this._setDebugData(view, byteOffset, byteLength);
2✔
83
  }
84

85
  async readAsync(byteOffset = 0, byteLength?: number): Promise<Uint8Array> {
17✔
86
    byteLength = byteLength ?? this.byteLength - byteOffset;
17✔
87

88
    if (byteOffset + byteLength > this.byteLength) {
17!
89
      throw new RangeError(`NullBuffer.readAsync(): read would overflow buffer`);
×
90
    }
91

92
    const view = new Uint8Array(this._storage, byteOffset, byteLength);
17✔
93
    return new Uint8Array(view); // return a copy
17✔
94
  }
95

96
  async mapAndReadAsync<T>(
97
    callback: BufferMapCallback<T>,
98
    byteOffset = 0,
2✔
99
    byteLength = this.byteLength - byteOffset
2✔
100
  ): Promise<T> {
101
    const view = new Uint8Array(this._storage, byteOffset, byteLength);
2✔
102
    const copy = new Uint8Array(view); // copy to protect memory
2✔
103
    return callback(copy.buffer, 'copied');
2✔
104
  }
105

106
  readSyncWebGL(): Uint8Array {
107
    throw new Error('NullBuffer.readSyncWebGL() not implemented');
×
108
  }
109
}
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