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

visgl / loaders.gl / 24139120841

08 Apr 2026 01:53PM UTC coverage: 65.319% (+30.2%) from 35.137%
24139120841

push

github

web-flow
chore: Replace puppeteer with playwright (#3350)

14216 of 18890 branches covered (75.26%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 1 file covered. (100.0%)

3248 existing lines in 369 files now uncovered.

73509 of 115413 relevant lines covered (63.69%)

5763.45 hits per line

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

10.91
/modules/core/src/lib/api/create-data-source.ts
UNCOV
1
// loaders.gl
×
UNCOV
2
// SPDX-License-Identifier: MIT
×
UNCOV
3
// Copyright (c) vis.gl contributors
×
UNCOV
4

×
UNCOV
5
import {Source, SourceArrayOptionsType, SourceArrayDataSourceType} from '@loaders.gl/loader-utils';
×
UNCOV
6

×
UNCOV
7
/**
×
UNCOV
8
 * Creates a source from a service
×
UNCOV
9
 * If type is not supplied, will try to automatically detect the the
×
UNCOV
10
 * @param url URL to the data source
×
UNCOV
11
 * @param type type of source. if not known, set to 'auto'
×
UNCOV
12
 * @returns an DataSource instance
×
UNCOV
13
 */
×
UNCOV
14
// DataSourceOptionsT extends DataSourceOptions = DataSourceOptions,
×
UNCOV
15
// DataSourceT extends DataSource = DataSource
×
UNCOV
16
export function createDataSource<SourceArrayT extends Source[]>(
×
17
  data: string | Blob,
×
18
  sources: Readonly<SourceArrayT>,
×
19
  options: Readonly<SourceArrayOptionsType<SourceArrayT>>
×
20
): SourceArrayDataSourceType<SourceArrayT> {
×
21
  const type = options?.core?.type || (options.type as unknown as string) || 'auto';
×
22
  const source = type === 'auto' ? selectSource(data, sources) : getSourceOfType(type, sources);
×
23

×
24
  if (!source) {
×
25
    throw new Error('Not a valid source type');
×
26
  }
×
27
  return source.createDataSource(data, options);
×
28
}
×
29

1✔
30
// TODO - use selectSource...
1✔
31

1✔
32
/** Guess service type from URL */
1✔
33
function selectSource<SourceArrayT extends Source[]>(
×
34
  url: string | Blob,
×
35
  sources: Readonly<SourceArrayT>
×
36
): SourceArrayT[number] | null {
×
37
  for (const service of sources) {
×
38
    // @ts-expect-error
×
39
    if (service.testURL && service.testURL(url)) {
×
40
      return service;
×
41
    }
×
42
  }
×
43

×
44
  return null;
×
45
}
×
46

1✔
47
/** Guess service type from URL */
1✔
48
function getSourceOfType(type: string, sources: Readonly<Source[]>): Source | null {
×
49
  for (const service of sources) {
×
50
    if (service.type === type) {
×
51
      return service;
×
52
    }
×
53
  }
×
54
  return null;
×
55
}
×
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