Code coverage report for RxJS/dist/cjs/operators/expand-support.js

Statements: 91.43% (64 / 70)      Branches: 70.45% (31 / 44)      Functions: 100% (12 / 12)      Lines: 93.55% (58 / 62)      Ignored: none     

All files » RxJS/dist/cjs/operators/ » expand-support.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    1   3   1   10   1   1   1   1   1   1   1   1 1 5   5   5 5     1 5     1     1   1 1   1 5   5   5 5 5 5 5 5 5         1 25 25 25 25 25     25 4   21 21               1 5 5 3       1 21 21 21 21     21 2       1 16     1     1
'use strict';
 
exports.__esModule = true;
 
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 _utilTryCatch = require('../util/tryCatch');
 
var _utilTryCatch2 = _interopRequireDefault(_utilTryCatch);
 
var _utilErrorObject = require('../util/errorObject');
 
var _OuterSubscriber2 = require('../OuterSubscriber');
 
var _OuterSubscriber3 = _interopRequireDefault(_OuterSubscriber2);
 
var _utilSubscribeToResult = require('../util/subscribeToResult');
 
var _utilSubscribeToResult2 = _interopRequireDefault(_utilSubscribeToResult);
 
var ExpandOperator = (function () {
    function ExpandOperator(project) {
        var concurrent = arguments.length <= 1 || arguments[1] === undefined ? Number.POSITIVE_INFINITY : arguments[1];
 
        _classCallCheck(this, ExpandOperator);
 
        this.project = project;
        this.concurrent = concurrent;
    }
 
    ExpandOperator.prototype.call = function call(subscriber) {
        return new ExpandSubscriber(subscriber, this.project, this.concurrent);
    };
 
    return ExpandOperator;
})();
 
exports.ExpandOperator = ExpandOperator;
 
var ExpandSubscriber = (function (_OuterSubscriber) {
    _inherits(ExpandSubscriber, _OuterSubscriber);
 
    function ExpandSubscriber(destination, project) {
        var concurrent = arguments.length <= 2 || arguments[2] === undefined ? Number.POSITIVE_INFINITY : arguments[2];
 
        _classCallCheck(this, ExpandSubscriber);
 
        _OuterSubscriber.call(this, destination);
        this.project = project;
        this.concurrent = concurrent;
        this.index = 0;
        this.active = 0;
        this.hasCompleted = false;
        Iif (concurrent < Number.POSITIVE_INFINITY) {
            this.buffer = [];
        }
    }
 
    ExpandSubscriber.prototype._next = function _next(value) {
        var index = this.index++;
        this.destination.next(value);
        Eif (this.active < this.concurrent) {
            var result = _utilTryCatch2['default'](this.project)(value, index);
            Iif (result === _utilErrorObject.errorObject) {
                this.destination.error(result.e);
            } else {
                if (result._isScalar) {
                    this._next(result.value);
                } else {
                    this.active++;
                    this.add(_utilSubscribeToResult2['default'](this, result, value, index));
                }
            }
        } else {
            this.buffer.push(value);
        }
    };
 
    ExpandSubscriber.prototype._complete = function _complete() {
        this.hasCompleted = true;
        if (this.hasCompleted && this.active === 0) {
            this.destination.complete();
        }
    };
 
    ExpandSubscriber.prototype.notifyComplete = function notifyComplete(innerSub) {
        var buffer = this.buffer;
        this.remove(innerSub);
        this.active--;
        Iif (buffer && buffer.length > 0) {
            this._next(buffer.shift());
        }
        if (this.hasCompleted && this.active === 0) {
            this.destination.complete();
        }
    };
 
    ExpandSubscriber.prototype.notifyNext = function notifyNext(outerValue, innerValue, outerIndex, innerIndex) {
        this._next(innerValue);
    };
 
    return ExpandSubscriber;
})(_OuterSubscriber3['default']);
 
exports.ExpandSubscriber = ExpandSubscriber;