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

visgl / loaders.gl / 20352515932

18 Dec 2025 09:56PM UTC coverage: 35.115% (-28.4%) from 63.485%
20352515932

push

github

web-flow
feat(loader-utils): Export is-type helpers (#3258)

1188 of 1998 branches covered (59.46%)

Branch coverage included in aggregate %.

147 of 211 new or added lines in 13 files covered. (69.67%)

30011 existing lines in 424 files now uncovered.

37457 of 108056 relevant lines covered (34.66%)

0.79 hits per line

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

86.15
/modules/core/src/iterators/make-iterator/make-iterator.ts
1
// loaders.gl
1✔
2
// SPDX-License-Identifier: MIT
1✔
3
// Copyright (c) vis.gl contributors
1✔
4

1✔
5
import type {ReadStream} from 'fs';
1✔
6

1✔
7
import {makeStringIterator} from './make-string-iterator';
1✔
8
import {makeArrayBufferIterator} from './make-array-buffer-iterator';
1✔
9
import {makeBlobIterator} from './make-blob-iterator';
1✔
10
import type {StreamIteratorOptions} from './make-stream-iterator';
1✔
11
import {makeStreamIterator} from './make-stream-iterator';
1✔
12
import {isBlob, isReadableStream, isResponse} from '@loaders.gl/loader-utils';
1✔
13

1✔
14
/**
1✔
15
 * @param [options.chunkSize]
1✔
16
 */
1✔
17
export type IteratorOptions = StreamIteratorOptions & {
1✔
18
  chunkSize?: number;
1✔
19
};
1✔
20

1✔
21
/**
1✔
22
 * Returns an iterator that breaks its input into chunks and yields them one-by-one.
1✔
23
 * @param data
1✔
24
 * @param options
1✔
25
 * @returns
1✔
26
 * This function can e.g. be used to enable data sources that can only be read atomically
1✔
27
 * (such as `Blob` and `File` via `FileReader`) to still be parsed in batches.
1✔
28
 */
1✔
29
export function makeIterator(
1✔
30
  data: ArrayBuffer | string | Blob | Response | ReadableStream | ReadStream,
4✔
31
  options?: IteratorOptions
4✔
32
): AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer> {
4✔
33
  if (typeof data === 'string') {
4✔
34
    // Note: Converts string chunks to binary
1✔
35
    return makeStringIterator(data, options);
1✔
36
  }
1✔
37
  if (data instanceof ArrayBuffer) {
4✔
38
    return makeArrayBufferIterator(data, options);
1✔
39
  }
1✔
40
  if (isBlob(data)) {
4!
NEW
41
    return makeBlobIterator(data, options);
×
UNCOV
42
  }
✔
43
  if (isReadableStream(data)) {
4✔
44
    return makeStreamIterator(data, options);
1✔
45
  }
1✔
46
  if (isResponse(data)) {
1✔
47
    const responseBody = data.body;
1✔
48
    if (!responseBody) {
1!
NEW
49
      throw new Error('Readable stream not available on Response');
×
NEW
50
    }
×
51
    return makeStreamIterator(responseBody as ReadableStream, options);
1✔
52
  }
1!
53
  throw new Error('makeIterator');
×
54
}
×
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