All files / utils/dist queue.js

85.29% Statements 29/34
50% Branches 4/8
85.71% Functions 6/7
84.38% Lines 27/32

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44  9x 9x 9x 9x   9x 9x 9x   9x   9x 2x 2x   2x       2x 2x 2x 2x     9x 2x   9x     9x 2x 2x 2x 2x 2x     9x   9x  
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Queue = void 0;
var global_1 = require("./global");
var Queue = (function () {
    function Queue() {
        this.stack = [];
        this.isFlushing = false;
        Iif (!('Promise' in global_1._global))
            return;
        this.micro = Promise.resolve();
    }
    Queue.prototype.addFn = function (fn) {
        var _this = this;
        Iif (typeof fn !== 'function')
            return;
        Iif (!('Promise' in global_1._global)) {
            fn();
            return;
        }
        this.stack.push(fn);
        Eif (!this.isFlushing) {
            this.isFlushing = true;
            this.micro.then(function () { return _this.flushStack(); });
        }
    };
    Queue.prototype.clear = function () {
        this.stack = [];
    };
    Queue.prototype.getStack = function () {
        return this.stack;
    };
    Queue.prototype.flushStack = function () {
        var temp = this.stack.slice(0);
        this.stack.length = 0;
        this.isFlushing = false;
        for (var i = 0; i < temp.length; i++) {
            temp[i]();
        }
    };
    return Queue;
}());
exports.Queue = Queue;
//# sourceMappingURL=queue.js.map