Code coverage report for RxJS/dist/cjs/schedulers/ImmediateScheduler.js

Statements: 97.3% (36 / 37)      Branches: 85.71% (12 / 14)      Functions: 100% (9 / 9)      Lines: 100% (33 / 33)      Ignored: none     

All files » RxJS/dist/cjs/schedulers/ » ImmediateScheduler.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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60    1   2   2   1   1   1   1   1 1 2   2 2 2     1 72     1 209 149   60 60 60 206   60     1 64   64     1 65     1 15     1     1 1
'use strict';
 
exports.__esModule = true;
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
 
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
 
var _ImmediateAction = require('./ImmediateAction');
 
var _ImmediateAction2 = _interopRequireDefault(_ImmediateAction);
 
var _FutureAction = require('./FutureAction');
 
var _FutureAction2 = _interopRequireDefault(_FutureAction);
 
var ImmediateScheduler = (function () {
    function ImmediateScheduler() {
        _classCallCheck(this, ImmediateScheduler);
 
        this.actions = [];
        this.active = false;
        this.scheduled = false;
    }
 
    ImmediateScheduler.prototype.now = function now() {
        return Date.now();
    };
 
    ImmediateScheduler.prototype.flush = function flush() {
        if (this.active || this.scheduled) {
            return;
        }
        this.active = true;
        var actions = this.actions;
        for (var action = undefined; action = actions.shift();) {
            action.execute();
        }
        this.active = false;
    };
 
    ImmediateScheduler.prototype.schedule = function schedule(work, delay, state) {
        if (delay === undefined) delay = 0;
 
        return delay <= 0 ? this.scheduleNow(work, state) : this.scheduleLater(work, delay, state);
    };
 
    ImmediateScheduler.prototype.scheduleNow = function scheduleNow(work, state) {
        return new _ImmediateAction2['default'](this, work).schedule(state);
    };
 
    ImmediateScheduler.prototype.scheduleLater = function scheduleLater(work, delay, state) {
        return new _FutureAction2['default'](this, work).schedule(state, delay);
    };
 
    return ImmediateScheduler;
})();
 
exports['default'] = ImmediateScheduler;
module.exports = exports['default'];