• 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

27.36
/modules/schema-utils/src/lib/utils/async-queue.ts
1
// From https://github.com/rauschma/async-iter-demo/tree/master/src under MIT license
1✔
2
// http://2ality.com/2016/10/asynchronous-iteration.html
1✔
3

1✔
4
class ArrayQueue<T> extends Array<T> {
1✔
5
  enqueue(value: T) {
1✔
UNCOV
6
    // Add at the end
×
UNCOV
7
    return this.push(value);
×
UNCOV
8
  }
×
9
  dequeue(): T {
1✔
UNCOV
10
    // Remove first element
×
UNCOV
11
    return this.shift() as T;
×
UNCOV
12
  }
×
13
}
1✔
14

1✔
15
export default class AsyncQueue<T> {
1✔
16
  private _values: ArrayQueue<T | Error>;
1!
UNCOV
17
  private _settlers: ArrayQueue<{resolve: (value: any) => void; reject: (reason?: any) => void}>;
×
UNCOV
18
  private _closed: boolean;
×
19

1✔
20
  constructor() {
1✔
UNCOV
21
    // enqueues > dequeues
×
UNCOV
22
    this._values = new ArrayQueue<T>();
×
UNCOV
23
    // dequeues > enqueues
×
UNCOV
24
    this._settlers = new ArrayQueue<{
×
UNCOV
25
      resolve: (value: any) => void;
×
UNCOV
26
      reject: (reason?: any) => void;
×
UNCOV
27
    }>();
×
UNCOV
28
    this._closed = false;
×
UNCOV
29
  }
×
30

1✔
31
  close(): void {
1✔
UNCOV
32
    while (this._settlers.length > 0) {
×
UNCOV
33
      this._settlers.dequeue().resolve({done: true});
×
UNCOV
34
    }
×
UNCOV
35
    this._closed = true;
×
UNCOV
36
  }
×
37

1✔
38
  [Symbol.asyncIterator](): AsyncIterator<T> {
1✔
UNCOV
39
    return this;
×
UNCOV
40
  }
×
41

1✔
42
  enqueue(value: T | Error): void {
1✔
UNCOV
43
    if (this._closed) {
×
44
      throw new Error('Closed');
×
45
    }
×
UNCOV
46

×
UNCOV
47
    if (this._settlers.length > 0) {
×
UNCOV
48
      if (this._values.length > 0) {
×
49
        throw new Error('Illegal internal state');
×
50
      }
×
UNCOV
51
      const settler = this._settlers.dequeue();
×
UNCOV
52
      if (value instanceof Error) {
×
53
        settler.reject(value);
×
UNCOV
54
      } else {
×
UNCOV
55
        settler.resolve({value});
×
UNCOV
56
      }
×
UNCOV
57
    } else {
×
UNCOV
58
      this._values.enqueue(value);
×
UNCOV
59
    }
×
UNCOV
60
  }
×
61

1✔
62
  /**
1✔
63
   * @returns a Promise for an IteratorResult
1✔
64
   */
1✔
65
  next(): Promise<any> {
1✔
UNCOV
66
    if (this._values.length > 0) {
×
UNCOV
67
      const value = this._values.dequeue();
×
UNCOV
68
      if (value instanceof Error) {
×
69
        return Promise.reject(value);
×
70
      }
×
UNCOV
71
      return Promise.resolve({value});
×
UNCOV
72
    }
×
UNCOV
73

×
UNCOV
74
    if (this._closed) {
×
UNCOV
75
      if (this._settlers.length > 0) {
×
76
        throw new Error('Illegal internal state');
×
77
      }
×
UNCOV
78
      return Promise.resolve({done: true});
×
UNCOV
79
    }
×
UNCOV
80
    // Wait for new values to be enqueued
×
UNCOV
81
    return new Promise((resolve, reject) => {
×
UNCOV
82
      this._settlers.enqueue({resolve, reject});
×
UNCOV
83
    });
×
UNCOV
84
  }
×
85
}
1✔
86

1✔
87
/**
1✔
88
 * @returns a Promise for an Array with the elements in `asyncIterable`
1✔
89
 */
1✔
90
export async function takeAsync(
×
91
  asyncIterable: AsyncIterable<any>,
×
92
  count = Infinity
×
93
): Promise<any[]> {
×
94
  const result: Array<any> = [];
×
95
  const iterator = asyncIterable[Symbol.asyncIterator]();
×
96
  while (result.length < count) {
×
97
    const {value, done} = await iterator.next();
×
98
    if (done) {
×
99
      break;
×
100
    }
×
101
    result.push(value);
×
102
  }
×
103
  return result;
×
104
}
×
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