class QueueItem { constructor(value) { this.value = value; this.next = void 0; } } class Queue { constructor() { this.first = void 0; this.last = void 0; } enqueue(value) { var wasEmpty = !this.first; var item = new QueueItem(value); if (wasEmpty) { this.first = item; } else { this.last.next = item; } this.last = item; return wasEmpty; } dequeue() { var first = this.first; if (first) { this.first = first.next; } if (first === this.last) { this.last = void 0; } return first.value; } isEmpty() { return !this.first; } }