Code coverage report for cjs/operators/extended/elementAt.js

Statements: 95.92% (47 / 49)      Branches: 70.83% (17 / 24)      Functions: 100% (11 / 11)      Lines: 100% (41 / 41)      Ignored: none     

All files » cjs/operators/extended/ » elementAt.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    1 1   2   1   11   1   1   1   1   1 6     1 1 6   6 6 6 1       1 5     1     1 1   1 5   5 5 5         1 10 3 3       1 2 2 2 1   1     2     1     1  
'use strict';
 
exports.__esModule = true;
exports['default'] = elementAt;
 
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 _utilArgumentOutOfRangeError = require('../../util/ArgumentOutOfRangeError');
 
var _utilArgumentOutOfRangeError2 = _interopRequireDefault(_utilArgumentOutOfRangeError);
 
function elementAt(index, defaultValue) {
    return this.lift(new ElementAtOperator(index, defaultValue));
}
 
var ElementAtOperator = (function () {
    function ElementAtOperator(index, defaultValue) {
        _classCallCheck(this, ElementAtOperator);
 
        this.index = index;
        this.defaultValue = defaultValue;
        if (index < 0) {
            throw new _utilArgumentOutOfRangeError2['default']();
        }
    }
 
    ElementAtOperator.prototype.call = function call(subscriber) {
        return new ElementAtSubscriber(subscriber, this.index, this.defaultValue);
    };
 
    return ElementAtOperator;
})();
 
var ElementAtSubscriber = (function (_Subscriber) {
    _inherits(ElementAtSubscriber, _Subscriber);
 
    function ElementAtSubscriber(destination, index, defaultValue) {
        _classCallCheck(this, ElementAtSubscriber);
 
        _Subscriber.call(this, destination);
        this.index = index;
        this.defaultValue = defaultValue;
    }
 
    //# sourceMappingURL=elementAt.js.map
 
    ElementAtSubscriber.prototype._next = function _next(x) {
        if (this.index-- === 0) {
            this.destination.next(x);
            this.destination.complete();
        }
    };
 
    ElementAtSubscriber.prototype._complete = function _complete() {
        var destination = this.destination;
        Eif (this.index >= 0) {
            if (typeof this.defaultValue !== 'undefined') {
                destination.next(this.defaultValue);
            } else {
                destination.error(new _utilArgumentOutOfRangeError2['default']());
            }
        }
        destination.complete();
    };
 
    return ElementAtSubscriber;
})(_Subscriber3['default']);
 
module.exports = exports['default'];
//# sourceMappingURL=elementAt.js.map