Code coverage report for cjs/operators/every.js

Statements: 82.05% (64 / 78)      Branches: 53.13% (17 / 32)      Functions: 92.31% (12 / 13)      Lines: 82.86% (58 / 70)      Ignored: none     

All files » cjs/operators/ » every.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    1 1   6   1   24   1   1   1   1   1   1   1   1   1   1   1   1   1   1 12 12 12               12                     12     1 1 12   12 12 12     1 12     1     1 1   1 12   12 12 12 12 12 12 12           1 9 9     1 20 20     20 20   20 4       1 5     1     1  
'use strict';
 
exports.__esModule = true;
exports['default'] = every;
 
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 _observablesScalarObservable = require('../observables/ScalarObservable');
 
var _observablesScalarObservable2 = _interopRequireDefault(_observablesScalarObservable);
 
var _observablesArrayObservable = require('../observables/ArrayObservable');
 
var _observablesArrayObservable2 = _interopRequireDefault(_observablesArrayObservable);
 
var _observablesErrorObservable = require('../observables/ErrorObservable');
 
var _observablesErrorObservable2 = _interopRequireDefault(_observablesErrorObservable);
 
var _Subscriber2 = require('../Subscriber');
 
var _Subscriber3 = _interopRequireDefault(_Subscriber2);
 
var _utilTryCatch = require('../util/tryCatch');
 
var _utilTryCatch2 = _interopRequireDefault(_utilTryCatch);
 
var _utilErrorObject = require('../util/errorObject');
 
var _utilBindCallback = require('../util/bindCallback');
 
var _utilBindCallback2 = _interopRequireDefault(_utilBindCallback);
 
function every(predicate, thisArg) {
    var source = this;
    var result = undefined;
    Iif (source._isScalar) {
        result = _utilTryCatch2['default'](predicate)(source.value, 0, source);
        if (result === _utilErrorObject.errorObject) {
            return new _observablesErrorObservable2['default'](_utilErrorObject.errorObject.e, source.scheduler);
        } else {
            return new _observablesScalarObservable2['default'](result, source.scheduler);
        }
    }
    Iif (source instanceof _observablesArrayObservable2['default']) {
        var array = source.array;
        var _result = _utilTryCatch2['default'](function (array, predicate) {
            return array.every(predicate);
        })(array, predicate);
        if (_result === _utilErrorObject.errorObject) {
            return new _observablesErrorObservable2['default'](_utilErrorObject.errorObject.e, source.scheduler);
        } else {
            return new _observablesScalarObservable2['default'](_result, source.scheduler);
        }
    }
    return source.lift(new EveryOperator(predicate, thisArg, source));
}
 
var EveryOperator = (function () {
    function EveryOperator(predicate, thisArg, source) {
        _classCallCheck(this, EveryOperator);
 
        this.predicate = predicate;
        this.thisArg = thisArg;
        this.source = source;
    }
 
    EveryOperator.prototype.call = function call(observer) {
        return new EverySubscriber(observer, this.predicate, this.thisArg, this.source);
    };
 
    return EveryOperator;
})();
 
var EverySubscriber = (function (_Subscriber) {
    _inherits(EverySubscriber, _Subscriber);
 
    function EverySubscriber(destination, predicate, thisArg, source) {
        _classCallCheck(this, EverySubscriber);
 
        _Subscriber.call(this, destination);
        this.thisArg = thisArg;
        this.source = source;
        this.predicate = undefined;
        this.index = 0;
        Eif (typeof predicate === 'function') {
            this.predicate = _utilBindCallback2['default'](predicate, thisArg, 3);
        }
    }
 
    //# sourceMappingURL=every.js.map
 
    EverySubscriber.prototype.notifyComplete = function notifyComplete(everyValueMatch) {
        this.destination.next(everyValueMatch);
        this.destination.complete();
    };
 
    EverySubscriber.prototype._next = function _next(value) {
        var predicate = this.predicate;
        Iif (predicate === undefined) {
            this.destination.error(new TypeError('predicate must be a function'));
        }
        var result = _utilTryCatch2['default'](predicate)(value, this.index++, this.source);
        Iif (result === _utilErrorObject.errorObject) {
            this.destination.error(result.e);
        } else if (!result) {
            this.notifyComplete(false);
        }
    };
 
    EverySubscriber.prototype._complete = function _complete() {
        this.notifyComplete(true);
    };
 
    return EverySubscriber;
})(_Subscriber3['default']);
 
module.exports = exports['default'];
//# sourceMappingURL=every.js.map