Code coverage report for cjs/scheduler/QueueScheduler.js

Statements: 100% (27 / 27)      Branches: 100% (8 / 8)      Functions: 100% (7 / 7)      Lines: 100% (26 / 26)      Ignored: none     

All files » cjs/scheduler/ » QueueScheduler.js
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 381 1 1 1 2 2 2   1 167   1 487 351   136 136 136 489   136   1 149 149       1 124   1 23   1   1  
var QueueAction_1 = require('./QueueAction');
var FutureAction_1 = require('./FutureAction');
var QueueScheduler = (function () {
    function QueueScheduler() {
        this.actions = [];
        this.active = false;
        this.scheduled = false;
    }
    QueueScheduler.prototype.now = function () {
        return Date.now();
    };
    QueueScheduler.prototype.flush = function () {
        if (this.active || this.scheduled) {
            return;
        }
        this.active = true;
        var actions = this.actions;
        for (var action = void 0; action = actions.shift();) {
            action.execute();
        }
        this.active = false;
    };
    QueueScheduler.prototype.schedule = function (work, delay, state) {
        if (delay === void 0) { delay = 0; }
        return (delay <= 0) ?
            this.scheduleNow(work, state) :
            this.scheduleLater(work, delay, state);
    };
    QueueScheduler.prototype.scheduleNow = function (work, state) {
        return new QueueAction_1.QueueAction(this, work).schedule(state);
    };
    QueueScheduler.prototype.scheduleLater = function (work, delay, state) {
        return new FutureAction_1.FutureAction(this, work).schedule(state, delay);
    };
    return QueueScheduler;
})();
exports.QueueScheduler = QueueScheduler;
//# sourceMappingURL=QueueScheduler.js.map