# Code coverage report for RxJS/dist/cjs/operators/retry.js

## Statements: 95.35% (41 / 43) Branches: 75% (18 / 24) Functions: 100% (11 / 11) Lines: 100% (35 / 35) Ignored: none

All files » RxJS/dist/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

    1
    1

    1

    1

    6

    1

    1

    1
    3

    3

    1
    1
    3

    3
    3

    1
    3

    1

    1
    1

    1
    3

    3
    3
    3
    3

    1
    11
    11
    1

    10

    1
    10

    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 _Subscriber2 = require('../Subscriber');

    var _Subscriber3 = _interopRequireDefault(_Subscriber2);

    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, original) {
            _classCallCheck(this, RetryOperator);

            this.count = count;
            this.original = original;
        }

        RetryOperator.prototype.call = function call(subscriber) {
            return new RetrySubscriber(subscriber, this.count, this.original);
        };

        return RetryOperator;
    })();

    var RetrySubscriber = (function (_Subscriber) {
        _inherits(RetrySubscriber, _Subscriber);

        function RetrySubscriber(destination, count, original) {
            _classCallCheck(this, RetrySubscriber);

            _Subscriber.call(this, destination);
            this.count = count;
            this.original = original;
            this.retries = 0;
        }

        RetrySubscriber.prototype._error = function _error(err) {
            var count = this.count;
            if (count && count === (this.retries += 1)) {
                this.destination.error(err);
            } else {
                this.resubscribe();
            }
        };

        RetrySubscriber.prototype.resubscribe = function resubscribe() {
            this.original.subscribe(this);
        };

        return RetrySubscriber;
    })(_Subscriber3['default']);

    module.exports = exports['default'];