Code coverage report for cjs/operators/retry.js

Statements: 97.4% (75 / 77)      Branches: 77.78% (28 / 36)      Functions: 100% (19 / 19)      Lines: 100% (69 / 69)      Ignored: none     

All files » cjs/operators/ » retry.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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125    1 1   1   2   77   1   1   1 11   11     1 1 11   11 11     1 11     1     1 1   1 11   11 11 11 11 11     1 15     1 7 7 7       1 2 2     1 22 22 18   4       1 55   55 55 55     1     1 1   1 55   55   55 55 55 55         1 24     1 50 50 50 50 2   48       1 2     1     1  
'use strict';
 
exports.__esModule = true;
exports['default'] = retry;
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
 
function _inherits(subClass, superClass) { Iif (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); Eif (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
 
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
 
var _Subscriber3 = require('../Subscriber');
 
var _Subscriber4 = _interopRequireDefault(_Subscriber3);
 
function retry() {
    var count = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];
 
    return this.lift(new RetryOperator(count, this));
}
 
var RetryOperator = (function () {
    function RetryOperator(count, source) {
        _classCallCheck(this, RetryOperator);
 
        this.count = count;
        this.source = source;
    }
 
    RetryOperator.prototype.call = function call(subscriber) {
        return new FirstRetrySubscriber(subscriber, this.count, this.source);
    };
 
    return RetryOperator;
})();
 
var FirstRetrySubscriber = (function (_Subscriber) {
    _inherits(FirstRetrySubscriber, _Subscriber);
 
    function FirstRetrySubscriber(destination, count, source) {
        _classCallCheck(this, FirstRetrySubscriber);
 
        _Subscriber.call(this, null);
        this.destination = destination;
        this.count = count;
        this.source = source;
        this.lastSubscription = this;
    }
 
    FirstRetrySubscriber.prototype._next = function _next(value) {
        this.destination.next(value);
    };
 
    FirstRetrySubscriber.prototype.error = function error(_error) {
        Eif (!this.isUnsubscribed) {
            _Subscriber.prototype.unsubscribe.call(this);
            this.resubscribe();
        }
    };
 
    FirstRetrySubscriber.prototype._complete = function _complete() {
        _Subscriber.prototype.unsubscribe.call(this);
        this.destination.complete();
    };
 
    FirstRetrySubscriber.prototype.unsubscribe = function unsubscribe() {
        var lastSubscription = this.lastSubscription;
        if (lastSubscription === this) {
            _Subscriber.prototype.unsubscribe.call(this);
        } else {
            lastSubscription.unsubscribe();
        }
    };
 
    FirstRetrySubscriber.prototype.resubscribe = function resubscribe() {
        var retried = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];
 
        this.lastSubscription.unsubscribe();
        var nextSubscriber = new RetryMoreSubscriber(this, this.count, retried + 1);
        this.lastSubscription = this.source.subscribe(nextSubscriber);
    };
 
    return FirstRetrySubscriber;
})(_Subscriber4['default']);
 
var RetryMoreSubscriber = (function (_Subscriber2) {
    _inherits(RetryMoreSubscriber, _Subscriber2);
 
    function RetryMoreSubscriber(parent, count) {
        var retried = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2];
 
        _classCallCheck(this, RetryMoreSubscriber);
 
        _Subscriber2.call(this, null);
        this.parent = parent;
        this.count = count;
        this.retried = retried;
    }
 
    //# sourceMappingURL=retry.js.map
 
    RetryMoreSubscriber.prototype._next = function _next(value) {
        this.parent.destination.next(value);
    };
 
    RetryMoreSubscriber.prototype._error = function _error(err) {
        var parent = this.parent;
        var retried = this.retried;
        var count = this.count;
        if (count && retried === count) {
            parent.destination.error(err);
        } else {
            parent.resubscribe(retried);
        }
    };
 
    RetryMoreSubscriber.prototype._complete = function _complete() {
        this.parent.destination.complete();
    };
 
    return RetryMoreSubscriber;
})(_Subscriber4['default']);
 
module.exports = exports['default'];
//# sourceMappingURL=retry.js.map