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

visgl / loaders.gl / 20268670319

16 Dec 2025 12:55PM UTC coverage: 58.164% (-0.01%) from 58.175%
20268670319

push

github

web-flow
chore(crypto)  make md5 wasm decoder Buffer independent (#3256)

7161 of 9602 branches covered (74.58%)

Branch coverage included in aggregate %.

40 of 87 new or added lines in 1 file covered. (45.98%)

5 existing lines in 2 files now uncovered.

66957 of 117827 relevant lines covered (56.83%)

2453.18 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) {
20!
49
        throw new Error('Illegal internal state');
×
50
      }
×
51
      const settler = this._settlers.dequeue();
20✔
52
      if (value instanceof Error) {
20!
53
        settler.reject(value);
×
54
      } else {
20✔
55
        settler.resolve({value});
20✔
56
      }
20✔
57
    } else {
109✔
58
      this._values.enqueue(value);
89✔
59
    }
89✔
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();
14✔
68
      if (value instanceof Error) {
14!
69
        return Promise.reject(value);
×
70
      }
×
71
      return Promise.resolve({value});
14✔
72
    }
14✔
73

37✔
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
20✔
81
    return new Promise((resolve, reject) => {
20✔
82
      this._settlers.enqueue({resolve, reject});
20✔
83
    });
20✔
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