export class MessageQueue { private queue = new Array(); /// Empty the queue clear() { this.queue = []; } /// Add a new message to the queue enqueue(element: T) { this.queue.push(element); } /// Read all the messages in the queue and remove them in one operation dequeue(): Array { const q = this.queue; this.queue = []; return q; } }