• 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

74.23
/modules/core/src/lib/progress/fetch-progress.ts
1
// loaders.gl
1✔
2
// SPDX-License-Identifier: MIT
1✔
3
// Copyright (c) vis.gl contributors
1✔
4

1✔
UNCOV
5
// Forked from github AnthumChris/fetch-progress-indicators under MIT license
×
6

1✔
7
/**
1✔
8
 * Intercepts the Response stream and creates a new Response
1✔
9
 */
1✔
10
export async function fetchProgress(
1✔
11
  response: Response | Promise<Response>,
1✔
12
  onProgress: any, // TODO better callback types
1!
13
  onDone = () => {},
1✔
14
  onError = () => {}
1✔
15
) {
1✔
16
  response = await response;
1!
17
  if (!response.ok) {
1!
18
    // ERROR checking needs to be done separately
×
19
    return response;
×
20
  }
×
21
  const body = response.body;
1✔
22
  if (!body) {
1!
23
    // 'ReadableStream not yet supported in this browser.
✔
24
    return response;
1✔
25
  }
1✔
26
  const contentLength = response.headers.get('content-length') || 0;
1!
27
  const totalBytes = contentLength ? parseInt(contentLength) : 0;
1!
28
  if (!(totalBytes > 0)) {
2!
29
    return response;
2✔
30
  }
2✔
31
  // Currently override only implemented in browser
2✔
32
  if (typeof ReadableStream === 'undefined' || !body.getReader) {
2!
33
    return response;
1✔
34
  }
1✔
35

1✔
36
  // Create a new stream that invisbly wraps original stream
1✔
37
  const progressStream = new ReadableStream({
1✔
38
    async start(controller) {
1✔
39
      const reader = body.getReader();
1✔
40
      await read(controller, reader, 0, totalBytes, onProgress, onDone, onError);
1✔
41
    }
1✔
42
  });
2!
43

×
44
  return new Response(progressStream);
×
45
}
×
UNCOV
46

×
UNCOV
47
// Forward to original streams controller
×
48
// TODO - this causes a crazy deep "async stack"... rewrite as async iterator?
1✔
49
// eslint-disable-next-line max-params
1✔
50
async function read(
2✔
51
  controller: any,
2✔
52
  reader: any,
2✔
53
  loadedBytes: number,
2✔
54
  totalBytes: number,
2✔
55
  onProgress: Function,
2✔
56
  onDone: Function,
2✔
57
  onError: Function
2✔
58
): Promise<void> {
2✔
59
  try {
2✔
60
    const {done, value} = await reader.read();
2✔
61
    if (done) {
2✔
62
      onDone();
1✔
63
      controller.close();
1✔
64
      return;
1✔
65
    }
1✔
66
    loadedBytes += value.byteLength;
1✔
67
    const percent = Math.round((loadedBytes / totalBytes) * 100);
1✔
68
    onProgress(percent, {loadedBytes, totalBytes});
1✔
69
    controller.enqueue(value);
1✔
70
    await read(controller, reader, loadedBytes, totalBytes, onProgress, onDone, onError);
1✔
71
  } catch (error) {
2!
72
    controller.error(error);
×
73
    onError(error);
×
74
  }
×
75
}
2✔
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