# Code coverage report for RxJS/dist/cjs/observables/FromObservable.js

## Statements: 91.38% (53 / 58) Branches: 64.71% (22 / 34) Functions: 100% (7 / 7) Lines: 94% (47 / 50) Ignored: none

All files » RxJS/dist/cjs/observables/ » FromObservable.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

    1

    7

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1

    1
    1

    1
    1

    1
    1
    1

    1
    35

    35
    35
    7
    28
    25
    3
    1

    1
    2
    2

    1
    1
    1
    1
    1

    1

    1
    1'use strict';

    exports.__esModule = true;

    function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

    function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

    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; }

    var _PromiseObservable = require('./PromiseObservable');

    var _PromiseObservable2 = _interopRequireDefault(_PromiseObservable);

    var _IteratorObservable = require('./IteratorObservable');

    var _IteratorObservable2 = _interopRequireDefault(_IteratorObservable);

    var _ArrayObservable = require('./ArrayObservable');

    var _ArrayObservable2 = _interopRequireDefault(_ArrayObservable);

    var _utilSymbol_observable = require('../util/Symbol_observable');

    var _utilSymbol_observable2 = _interopRequireDefault(_utilSymbol_observable);

    var _utilSymbol_iterator = require('../util/Symbol_iterator');

    var _utilSymbol_iterator2 = _interopRequireDefault(_utilSymbol_iterator);

    var _Observable2 = require('../Observable');

    var _Observable3 = _interopRequireDefault(_Observable2);

    var _operatorsObserveOnSupport = require('../operators/observeOn-support');

    var _schedulersImmediate = require('../schedulers/immediate');

    var _schedulersImmediate2 = _interopRequireDefault(_schedulersImmediate);

    var isArray = Array.isArray;

    var FromObservable = (function (_Observable) {
        _inherits(FromObservable, _Observable);

        function FromObservable(ish, scheduler) {
            _classCallCheck(this, FromObservable);

            _Observable.call(this, null);
            this.ish = ish;
            this.scheduler = scheduler;
        }

        FromObservable.create = function create(ish) {
            var scheduler = arguments.length <= 1 || arguments[1] === undefined ? _schedulersImmediate2['default'] : arguments[1];

            Eif (ish) {
                if (isArray(ish)) {
                    return new _ArrayObservable2['default'](ish, scheduler);
                } else if (typeof ish.then === 'function') {
                    return new _PromiseObservable2['default'](ish, scheduler);
                } else if (typeof ish[_utilSymbol_observable2['default']] === 'function') {
                    Iif (ish instanceof _Observable3['default']) {
                        return ish;
                    }
                    return new FromObservable(ish, scheduler);
                } else Eif (typeof ish[_utilSymbol_iterator2['default']] === 'function') {
                    return new _IteratorObservable2['default'](ish, null, null, scheduler);
                }
            }
            throw new TypeError(typeof ish + ' is not observable');
        };

        FromObservable.prototype._subscribe = function _subscribe(subscriber) {
            var ish = this.ish;
            var scheduler = this.scheduler;
            Eif (scheduler === _schedulersImmediate2['default']) {
                return this.ish[_utilSymbol_observable2['default']]().subscribe(subscriber);
            } else {
                return this.ish[_utilSymbol_observable2['default']]().subscribe(new _operatorsObserveOnSupport.ObserveOnSubscriber(subscriber, scheduler, 0));
            }
        };

        return FromObservable;
    })(_Observable3['default']);

    exports['default'] = FromObservable;
    module.exports = exports['default'];