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

visgl / loaders.gl / 25070233425

28 Apr 2026 06:20PM UTC coverage: 59.434% (+0.01%) from 59.423%
25070233425

push

github

web-flow
website: Add tabs for navigating between format docs (#3407)

11310 of 20887 branches covered (54.15%)

Branch coverage included in aggregate %.

89 of 136 new or added lines in 13 files covered. (65.44%)

1742 existing lines in 132 files now uncovered.

23500 of 37682 relevant lines covered (62.36%)

16296.63 hits per line

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

50.0
/modules/core/src/lib/api/select-source.ts
1
// loaders.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
import type {SourceLoader} from '@loaders.gl/loader-utils';
6
import {selectLoaderSync} from './select-loader';
7

8
/** Guess service type from URL */
9
export function selectSource(
10
  url: string | Blob,
11
  sources: SourceLoader[],
12
  options?: {
13
    /** Provide id of a source to select that source. Omit or provide 'auto' to test the source*/
14
    type?: string;
15
    nothrow?: boolean;
16
  }
17
): SourceLoader | null {
UNCOV
18
  const type = options?.type || 'auto';
6!
UNCOV
19
  let selectedSource: SourceLoader | null = null;
6✔
UNCOV
20
  if (type === 'auto') {
6!
UNCOV
21
    selectedSource = selectLoaderSync(url, sources, {core: {nothrow: true}}) as SourceLoader | null;
6✔
22
  } else {
23
    selectedSource = getSourceOfType(type, sources);
×
24
  }
25

UNCOV
26
  if (!selectedSource && !options?.nothrow) {
6!
27
    throw new Error('Not a valid image source type');
×
28
  }
29

UNCOV
30
  return selectedSource;
6✔
31
}
32

33
/** Guess service type from URL */
34
function getSourceOfType(type: string, sources: SourceLoader[]): SourceLoader | null {
35
  for (const service of sources) {
×
36
    if (service.type === type) {
×
37
      return service;
×
38
    }
39
  }
40
  return null;
×
41
}
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