Code coverage report for cjs/operators/last.js

Statements: 91.89% (68 / 74)      Branches: 73.33% (22 / 30)      Functions: 100% (11 / 11)      Lines: 93.94% (62 / 66)      Ignored: none     

All files » cjs/operators/ » last.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    1 1   3   1   16   1   1   1   1   1   1   1   1 8     1 1 8   8 8 8 8     1 8     1     1 1   1 8   8 8 8 8 8 8 8 8 2 2           1 13 13 13   13 13 8 8       8 3 1 1         3 3     5 5       1 7 7 5 5   2       1     1  
'use strict';
 
exports.__esModule = true;
exports['default'] = last;
 
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);
 
var _utilTryCatch = require('../util/tryCatch');
 
var _utilTryCatch2 = _interopRequireDefault(_utilTryCatch);
 
var _utilErrorObject = require('../util/errorObject');
 
var _utilEmptyError = require('../util/EmptyError');
 
var _utilEmptyError2 = _interopRequireDefault(_utilEmptyError);
 
function last(predicate, resultSelector, defaultValue) {
    return this.lift(new LastOperator(predicate, resultSelector, defaultValue, this));
}
 
var LastOperator = (function () {
    function LastOperator(predicate, resultSelector, defaultValue, source) {
        _classCallCheck(this, LastOperator);
 
        this.predicate = predicate;
        this.resultSelector = resultSelector;
        this.defaultValue = defaultValue;
        this.source = source;
    }
 
    LastOperator.prototype.call = function call(observer) {
        return new LastSubscriber(observer, this.predicate, this.resultSelector, this.defaultValue, this.source);
    };
 
    return LastOperator;
})();
 
var LastSubscriber = (function (_Subscriber) {
    _inherits(LastSubscriber, _Subscriber);
 
    function LastSubscriber(destination, predicate, resultSelector, defaultValue, source) {
        _classCallCheck(this, LastSubscriber);
 
        _Subscriber.call(this, destination);
        this.predicate = predicate;
        this.resultSelector = resultSelector;
        this.defaultValue = defaultValue;
        this.source = source;
        this.hasValue = false;
        this.index = 0;
        if (typeof defaultValue !== 'undefined') {
            this.lastValue = defaultValue;
            this.hasValue = true;
        }
    }
 
    //# sourceMappingURL=last.js.map
 
    LastSubscriber.prototype._next = function _next(value) {
        var predicate = this.predicate;
        var resultSelector = this.resultSelector;
        var destination = this.destination;
 
        var index = this.index++;
        if (predicate) {
            var found = _utilTryCatch2['default'](predicate)(value, index, this.source);
            Iif (found === _utilErrorObject.errorObject) {
                destination.error(_utilErrorObject.errorObject.e);
                return;
            }
            if (found) {
                if (resultSelector) {
                    value = _utilTryCatch2['default'](resultSelector)(value, index);
                    Iif (value === _utilErrorObject.errorObject) {
                        destination.error(_utilErrorObject.errorObject.e);
                        return;
                    }
                }
                this.lastValue = value;
                this.hasValue = true;
            }
        } else {
            this.lastValue = value;
            this.hasValue = true;
        }
    };
 
    LastSubscriber.prototype._complete = function _complete() {
        var destination = this.destination;
        if (this.hasValue) {
            destination.next(this.lastValue);
            destination.complete();
        } else {
            destination.error(new _utilEmptyError2['default']());
        }
    };
 
    return LastSubscriber;
})(_Subscriber3['default']);
 
module.exports = exports['default'];
//# sourceMappingURL=last.js.map