"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Queue = void 0;
class Queue {
    constructor(items) {
        this.items = items;
        this.items = this.items === undefined ? [] : this.items;
    }
    enqueue(item) {
        this.items.unshift(item);
        if (this.promiseResolve) {
            this.promiseResolve();
        }
    }
    async dequeue() {
        if (!this.items.length) {
            const promise = new Promise((resolve, reject) => {
                this.promiseResolve = resolve;
            });
            await promise;
            this.promiseResolve = null;
        }
        return this.items.pop();
    }
}
exports.Queue = Queue;
