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

visgl / loaders.gl / 22261831333

21 Feb 2026 06:16PM UTC coverage: 35.236% (+0.001%) from 35.235%
22261831333

Pull #3301

github

web-flow
Merge 47a5a7e15 into 5145c7b32
Pull Request #3301: chore: TypeScript 5.9, @types/node 25, yarn lock refresh

1199 of 2010 branches covered (59.65%)

Branch coverage included in aggregate %.

0 of 30 new or added lines in 10 files covered. (0.0%)

2 existing lines in 2 files now uncovered.

37553 of 107967 relevant lines covered (34.78%)

0.8 hits per line

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

77.42
/modules/loader-utils/src/lib/javascript-utils/is-type.ts
1
// loaders.gl
1✔
2
// SPDX-License-Identifier: MIT
1✔
3
// Copyright (c) vis.gl contributors
1✔
4

1✔
5
/* eslint-disable @typescript-eslint/unbound-method */
1✔
6

1✔
7
import type {Readable} from 'stream';
1✔
8

1✔
9
/** Minimal shape for Node.js Buffer-like values */
1✔
10
type NodeBufferLike = {buffer: ArrayBufferLike; isBuffer: true};
1✔
11

1✔
12
/** Minimal shape for Node.js writable streams */
1✔
13
type NodeWritableStream = {
1✔
14
  end: (...args: unknown[]) => unknown;
1✔
15
  write: (...args: unknown[]) => unknown;
1✔
16
  writable: boolean;
1✔
17
};
1✔
18

1✔
19
/** Minimal shape for WritableStream-like DOM implementations */
1✔
20
type WritableDOMStreamLike = WritableStream | {abort: () => unknown; getWriter: () => unknown};
1✔
21

1✔
22
/** A DOM or Node readable stream */
1✔
23
export type ReadableStreamType = ReadableStream | Readable;
1✔
24

1✔
25
/** Checks whether a value is a boolean */
1✔
26
const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean';
1✔
27

1✔
28
/** Checks whether a value is a function */
1✔
29
const isFunction = (value: unknown): value is (...args: unknown[]) => unknown =>
1✔
30
  typeof value === 'function';
6✔
31

1✔
32
/** Checks whether a value is a non-null object */
1✔
33
export const isObject = (value: unknown): value is object =>
1✔
34
  value !== null && typeof value === 'object';
20✔
35

1✔
36
/** Checks whether a value is a plain object (created by the Object constructor) */
1✔
37
export const isPureObject = (value: unknown): value is Record<string, unknown> =>
1✔
38
  isObject(value) && value.constructor === {}.constructor;
10✔
39

1✔
40
/** Checks whether a value is an ArrayBuffer */
1✔
41
export const isArrayBuffer = (value: unknown): value is ArrayBuffer =>
1✔
42
  typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer;
×
43

1✔
44
/** Checks whether a value is an ArrayBuffer */
1✔
45
export const isSharedArrayBuffer = (value: unknown): value is SharedArrayBuffer =>
1✔
46
  typeof SharedArrayBuffer !== 'undefined' && value instanceof SharedArrayBuffer;
21!
47

1✔
48
/** Checks whether a value is ArrayBuffer-like */
1✔
49
export const isArrayBufferLike = (value: unknown): value is ArrayBufferLike =>
1✔
50
  isObject(value) &&
×
51
  typeof (value as ArrayBufferLike).byteLength === 'number' &&
×
52
  typeof (value as ArrayBufferLike).slice === 'function';
×
53

1✔
54
/** Checks whether a value behaves like a promise */
1✔
55
export const isPromise = (value: unknown): value is Promise<unknown> =>
1✔
56
  isObject(value) && 'then' in value && isFunction((value as {then: unknown}).then);
2!
57

1✔
58
/** Checks whether a value implements the iterable protocol */
1✔
59
export const isIterable = (value: unknown): value is Iterable<unknown> =>
1✔
60
  Boolean(value) && isFunction((value as Iterable<unknown>)[Symbol.iterator]);
×
61

1✔
62
/** Checks whether a value implements the async iterable protocol */
1✔
63
export const isAsyncIterable = (value: unknown): value is AsyncIterable<unknown> =>
1✔
64
  Boolean(value) && isFunction((value as AsyncIterable<unknown>)[Symbol.asyncIterator]);
×
65

1✔
66
/** Checks whether a value is an iterator (has a next function) */
1✔
67
export const isIterator = (value: unknown): value is Iterator<unknown> =>
1✔
68
  Boolean(value) && isFunction((value as Iterator<unknown>).next);
2✔
69

1✔
70
/** Checks whether a value is a fetch Response or a duck-typed equivalent */
1✔
71
export const isResponse = (value: unknown): value is Response =>
1✔
72
  (typeof Response !== 'undefined' && value instanceof Response) ||
3✔
73
  (isObject(value) &&
2✔
74
    isFunction((value as {arrayBuffer?: unknown}).arrayBuffer) &&
2!
75
    isFunction((value as {text?: unknown}).text) &&
×
76
    isFunction((value as {json?: unknown}).json));
×
77

1✔
78
/** Checks whether a value is a File */
1✔
79
export const isFile = (value: unknown): value is File =>
1✔
80
  typeof File !== 'undefined' && value instanceof File;
×
81

1✔
82
/** Checks whether a value is a Blob */
1✔
83
export const isBlob = (value: unknown): value is Blob =>
1✔
84
  typeof Blob !== 'undefined' && value instanceof Blob;
4✔
85

1✔
86
/** Checks for Node.js Buffers without triggering bundlers to include the Buffer polyfill */
1✔
87
export const isBuffer = (value: unknown): value is NodeBufferLike =>
1✔
88
  Boolean(
×
89
    value &&
×
NEW
90
    typeof value === 'object' &&
×
NEW
91
    (value as Partial<NodeBufferLike>).isBuffer &&
×
NEW
92
    'buffer' in (value as NodeBufferLike)
×
UNCOV
93
  );
×
94

1✔
95
/** Checks whether a value looks like a DOM WritableStream */
1✔
96
export const isWritableDOMStream = (value: unknown): value is WritableDOMStreamLike =>
1✔
97
  isObject(value) &&
×
98
  isFunction((value as WritableDOMStreamLike).abort) &&
×
99
  isFunction((value as WritableDOMStreamLike).getWriter);
×
100

1✔
101
/** Checks whether a value looks like a DOM ReadableStream */
1✔
102
export const isReadableDOMStream = (value: unknown): value is ReadableStream =>
1✔
103
  (typeof ReadableStream !== 'undefined' && value instanceof ReadableStream) ||
2✔
104
  (isObject(value) &&
1✔
105
    isFunction((value as ReadableStream).tee) &&
1!
106
    isFunction((value as ReadableStream).cancel) &&
×
107
    isFunction((value as ReadableStream).getReader));
×
108
// Not implemented in Firefox: && isFunction(x.pipeTo)
1✔
109

1✔
110
/** Checks whether a value looks like a Node.js writable stream */
1✔
111
export const isWritableNodeStream = (value: unknown): value is NodeWritableStream =>
1✔
112
  isObject(value) &&
×
113
  isFunction((value as NodeWritableStream).end) &&
×
114
  isFunction((value as NodeWritableStream).write) &&
×
115
  isBoolean((value as NodeWritableStream).writable);
×
116

1✔
117
/** Checks whether a value looks like a Node.js readable stream */
1✔
118
export const isReadableNodeStream = (value: unknown): value is Readable =>
1✔
119
  isObject(value) &&
1✔
120
  isFunction((value as Readable).read) &&
1!
121
  isFunction((value as Readable).pipe) &&
×
122
  isBoolean((value as Readable).readable);
×
123

1✔
124
/** Checks whether a value is any readable stream (DOM or Node.js) */
1✔
125
export const isReadableStream = (value: unknown): value is ReadableStreamType =>
1✔
126
  isReadableDOMStream(value) || isReadableNodeStream(value);
2✔
127

1✔
128
/** Checks whether a value is any writable stream (DOM or Node.js) */
1✔
129
export const isWritableStream = (value: unknown): value is WritableStream | NodeWritableStream =>
1✔
130
  isWritableDOMStream(value) || isWritableNodeStream(value);
×
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