Code coverage report for cjs/operator/repeat.js

Statements: 100% (68 / 68)      Branches: 84.21% (16 / 19)      Functions: 100% (18 / 18)      Lines: 100% (64 / 64)      Ignored: none     

All files » cjs/operator/ » repeat.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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 921 4 2 2   1 1 1 36 36 4     32     1 1 1 32 32   1 35   1   1 1 1 35 35 35 35 35 35   1 75   1 3   1 29 29     1 67 67 59     8     1 80 80 80 80 24     56 56 56     1   1 1 1 56 56 56   1 91   1 1   1 51 51   1    
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) Eif (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Subscriber_1 = require('../Subscriber');
var empty_1 = require('../observable/empty');
function repeat(count) {
    if (count === void 0) { count = -1; }
    if (count === 0) {
        return new empty_1.EmptyObservable();
    }
    else {
        return this.lift(new RepeatOperator(count, this));
    }
}
exports.repeat = repeat;
var RepeatOperator = (function () {
    function RepeatOperator(count, source) {
        this.count = count;
        this.source = source;
    }
    RepeatOperator.prototype.call = function (subscriber) {
        return new FirstRepeatSubscriber(subscriber, this.count, this.source);
    };
    return RepeatOperator;
})();
var FirstRepeatSubscriber = (function (_super) {
    __extends(FirstRepeatSubscriber, _super);
    function FirstRepeatSubscriber(destination, count, source) {
        _super.call(this);
        this.destination = destination;
        this.count = count;
        this.source = source;
        destination.add(this);
        this.lastSubscription = this;
    }
    FirstRepeatSubscriber.prototype._next = function (value) {
        this.destination.next(value);
    };
    FirstRepeatSubscriber.prototype._error = function (err) {
        this.destination.error(err);
    };
    FirstRepeatSubscriber.prototype.complete = function () {
        Eif (!this.isUnsubscribed) {
            this.resubscribe(this.count);
        }
    };
    FirstRepeatSubscriber.prototype.unsubscribe = function () {
        var lastSubscription = this.lastSubscription;
        if (lastSubscription === this) {
            _super.prototype.unsubscribe.call(this);
        }
        else {
            lastSubscription.unsubscribe();
        }
    };
    FirstRepeatSubscriber.prototype.resubscribe = function (count) {
        var _a = this, destination = _a.destination, lastSubscription = _a.lastSubscription;
        destination.remove(lastSubscription);
        lastSubscription.unsubscribe();
        if (count - 1 === 0) {
            destination.complete();
        }
        else {
            var nextSubscriber = new MoreRepeatSubscriber(this, count - 1);
            this.lastSubscription = this.source.subscribe(nextSubscriber);
            destination.add(this.lastSubscription);
        }
    };
    return FirstRepeatSubscriber;
})(Subscriber_1.Subscriber);
var MoreRepeatSubscriber = (function (_super) {
    __extends(MoreRepeatSubscriber, _super);
    function MoreRepeatSubscriber(parent, count) {
        _super.call(this);
        this.parent = parent;
        this.count = count;
    }
    MoreRepeatSubscriber.prototype._next = function (value) {
        this.parent.destination.next(value);
    };
    MoreRepeatSubscriber.prototype._error = function (err) {
        this.parent.destination.error(err);
    };
    MoreRepeatSubscriber.prototype._complete = function () {
        var count = this.count;
        this.parent.resubscribe(count < 0 ? -1 : count);
    };
    return MoreRepeatSubscriber;
})(Subscriber_1.Subscriber);
//# sourceMappingURL=repeat.js.map