"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var rxjs_1 = require("rxjs");
var PQueue = require("p-queue");
var JobQueue = /** @class */ (function () {
    function JobQueue() {
        this.queue = new PQueue({ concurrency: 1 });
    }
    JobQueue.prototype.add = function (item) {
        var observable = new rxjs_1.Subject();
        this.queue.add(function () {
            var obs = item();
            obs.subscribe(observable);
            return obs.toPromise();
        });
        return observable;
    };
    JobQueue.prototype.onEmpty = function () {
        return this.queue.onEmpty();
    };
    Object.defineProperty(JobQueue.prototype, "size", {
        get: function () {
            return this.queue.size;
        },
        enumerable: true,
        configurable: true
    });
    return JobQueue;
}());
exports.JobQueue = JobQueue;
