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

visgl / loaders.gl / 25603943277

09 May 2026 02:49PM UTC coverage: 60.005%. Remained the same
25603943277

push

github

web-flow
chore: Add Node 26 to CI (#3420)

12967 of 23938 branches covered (54.17%)

Branch coverage included in aggregate %.

26843 of 42406 relevant lines covered (63.3%)

14662.34 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 {
18
  const type = options?.type || 'auto';
6!
19
  let selectedSource: SourceLoader | null = null;
6✔
20
  if (type === 'auto') {
6!
21
    selectedSource = selectLoaderSync(url, sources, {core: {nothrow: true}}) as SourceLoader | null;
6✔
22
  } else {
23
    selectedSource = getSourceOfType(type, sources);
×
24
  }
25

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

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