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

visgl / loaders.gl / 20382848403

19 Dec 2025 09:20PM UTC coverage: 35.219% (+0.1%) from 35.095%
20382848403

push

github

web-flow
feat: Upgrade to handle ArrayBufferLike (#3271)

1190 of 2002 branches covered (59.44%)

Branch coverage included in aggregate %.

157 of 269 new or added lines in 41 files covered. (58.36%)

3 existing lines in 3 files now uncovered.

37536 of 107957 relevant lines covered (34.77%)

0.79 hits per line

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

46.34
/modules/loader-utils/src/lib/node/buffer.ts
1
// loaders.gl
1✔
2
// SPDX-License-Identifier: MIT
1✔
3
// Copyright (c) vis.gl contributors
1✔
4

1✔
5
// Isolates Buffer references to ensure they are only bundled under Node.js (avoids big webpack polyfill)
1✔
6
// this file is selected by the package.json "browser" field).
1✔
7

1✔
8
/**
1✔
9
 * Convert Buffer to ArrayBuffer
1✔
10
 * Converts Node.js `Buffer` to `ArrayBuffer` (without triggering bundler to include Buffer polyfill on browser)
1✔
11
 * @todo better data type
1✔
12
 */
1✔
13
export function toArrayBuffer(buffer) {
1✔
14
  // TODO - per docs we should just be able to call buffer.buffer, but there are issues
×
15
  if (Buffer.isBuffer(buffer)) {
×
16
    const typedArray = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.length);
×
17
    return typedArray.slice().buffer;
×
18
  }
×
19
  return buffer;
×
20
}
×
21

1✔
22
/**
1✔
23
 * Convert (copy) ArrayBuffer to Buffer
1✔
24
 */
1✔
25
export function toBuffer(binaryData: ArrayBuffer | Buffer): Buffer {
1✔
26
  if (Buffer.isBuffer(binaryData)) {
×
27
    return binaryData;
×
28
  }
×
29

×
30
  if (ArrayBuffer.isView(binaryData)) {
×
NEW
31
    binaryData = binaryData.buffer as ArrayBuffer;
×
32
  }
×
33

×
34
  // TODO - move to loaders.gl/polyfills
×
35
  if (typeof Buffer !== 'undefined' && binaryData instanceof ArrayBuffer) {
×
36
    return Buffer.from(binaryData);
×
37
  }
×
38

×
39
  throw new Error('toBuffer');
×
40
}
×
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