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

visgl / loaders.gl / 20352100062

18 Dec 2025 09:37PM UTC coverage: 63.485% (+0.06%) from 63.426%
20352100062

push

github

web-flow
feat: LoaderOptions.core - improved loader type safety (#3112)

7255 of 9672 branches covered (75.01%)

Branch coverage included in aggregate %.

570 of 658 new or added lines in 65 files covered. (86.63%)

8 existing lines in 4 files now uncovered.

67412 of 107942 relevant lines covered (62.45%)

3436.69 hits per line

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

0.0
/modules/loader-utils/src/lib/sources/utils/utils.ts
1
// loaders.gl
×
2
// SPDX-License-Identifier: MIT
×
3
// Copyright (c) vis.gl contributors
×
4

×
5
import type {LoaderOptions} from '@loaders.gl/loader-utils';
×
6

×
7
/**
×
8
 * Gets the current fetch function from options
×
9
 * @todo - move to loader-utils module
×
10
 * @todo - use in core module counterpart
×
11
 * @param options
×
12
 * @param context
×
13
 */
×
14
export function getFetchFunction(options?: LoaderOptions) {
×
NEW
15
  const fetchFunction = options?.core?.fetch;
×
16

×
17
  // options.fetch can be a function
×
18
  if (fetchFunction && typeof fetchFunction === 'function') {
×
19
    return (url: string, fetchOptions?: RequestInit) => fetchFunction(url, fetchOptions);
×
20
  }
×
21

×
22
  // options.fetch can be an options object, use global fetch with those options
×
23
  const fetchOptions = options?.fetch;
×
24
  if (fetchOptions && typeof fetchOptions !== 'function') {
×
25
    return (url) => fetch(url, fetchOptions);
×
26
  }
×
27

×
28
  // else return the global fetch function
×
29
  return (url) => fetch(url);
×
30
}
×
31

×
32
export function mergeImageSourceLoaderProps<Props extends {loadOptions?: any}>(
×
33
  props: Props
×
34
): Required<Props> {
×
35
  // @ts-expect-error
×
36
  return {
×
37
    // Default fetch
×
38
    ...props,
×
39
    loadOptions: {
×
40
      ...props.loadOptions,
×
41
      fetch: getFetchFunction(props.loadOptions)
×
42
    }
×
43
  };
×
44
}
×
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