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

visgl / loaders.gl / 20339307699

18 Dec 2025 01:55PM UTC coverage: 63.423% (+0.05%) from 63.373%
20339307699

push

github

web-flow
feat(json): JSONPath improvements, error messages (#3259)

7229 of 9635 branches covered (75.03%)

Branch coverage included in aggregate %.

221 of 268 new or added lines in 1 file covered. (82.46%)

2 existing lines in 1 file now uncovered.

67159 of 107653 relevant lines covered (62.38%)

2685.06 hits per line

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

74.6
/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✔
6
    // Add at the end
109✔
7
    return this.push(value);
109✔
8
  }
109✔
9
  dequeue(): T {
1✔
10
    // Remove first element
34✔
11
    return this.shift() as T;
34✔
12
  }
34✔
13
}
1✔
14

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

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

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

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

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

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

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

36✔
74
    if (this._closed) {
51✔
75
      if (this._settlers.length > 0) {
17!
76
        throw new Error('Illegal internal state');
×
77
      }
×
78
      return Promise.resolve({done: true});
17✔
79
    }
17✔
80
    // Wait for new values to be enqueued
19✔
81
    return new Promise((resolve, reject) => {
19✔
82
      this._settlers.enqueue({resolve, reject});
19✔
83
    });
19✔
84
  }
51✔
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