• 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

0.0
/modules/polyfills/src/fetch/utils/decode-data-uri.node.ts
1
// loaders.gl
×
2
// SPDX-License-Identifier: MIT
×
3
// Copyright vis.gl contributors
×
4

×
5
// Based on binary-gltf-utils under MIT license: Copyright (c) 2016-17 Karl Cheng
×
NEW
6
import {toArrayBuffer} from '@loaders.gl/loader-utils';
×
7

×
8
/**
×
9
 * Parses a data URI into a buffer, as well as retrieving its declared MIME type.
×
10
 *
×
11
 * @param {string} uri - a data URI (assumed to be valid)
×
12
 * @returns {Object} { buffer, mimeType }
×
13
 */
×
14
export function decodeDataUri(uri: string): {arrayBuffer: ArrayBuffer; mimeType: string} {
×
15
  const dataIndex = uri.indexOf(',');
×
16

×
17
  let buffer;
×
18
  let mimeType;
×
19
  if (uri.slice(dataIndex - 7, dataIndex) === ';base64') {
×
20
    buffer = Buffer.from(uri.slice(dataIndex + 1), 'base64');
×
21
    mimeType = uri.slice(5, dataIndex - 7).trim();
×
22
  } else {
×
23
    buffer = Buffer.from(decodeURIComponent(uri.slice(dataIndex + 1)));
×
24
    mimeType = uri.slice(5, dataIndex).trim();
×
25
  }
×
26

×
27
  if (!mimeType) {
×
28
    mimeType = 'text/plain;charset=US-ASCII';
×
29
  } else if (mimeType.startsWith(';')) {
×
30
    mimeType = `text/plain${mimeType}`;
×
31
  }
×
32

×
33
  return {arrayBuffer: toArrayBuffer(buffer), mimeType};
×
34
}
×
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