# Code coverage report for RxJS/dist/cjs/Notification.js

## Statements: 70% (35 / 50) Branches: 42.86% (9 / 21) Functions: 72.73% (8 / 11) Lines: 70.21% (33 / 47) Ignored: none

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

    1

    1

    5995

    1

    1

    1
    1
    5995

    5995
    5995
    5995
    5995

    1
    3229

    2540

    146

    543

    1

    1

    1

    1
    5428
    5367

    61

    1
    626

    1
    1394

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

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

    var _Observable2 = _interopRequireDefault(_Observable);

    var Notification = (function () {
        function Notification(kind, value, exception) {
            _classCallCheck(this, Notification);

            this.kind = kind;
            this.value = value;
            this.exception = exception;
            this.hasValue = kind === 'N';
        }

        Notification.prototype.observe = function observe(observer) {
            switch (this.kind) {
                case 'N':
                    return observer.next(this.value);
                case 'E':
                    return observer.error(this.exception);
                case 'C':
                    return observer.complete();
            }
        };

        Notification.prototype['do'] = function _do(next, error, complete) {
            var kind = this.kind;
            switch (kind) {
                case 'N':
                    return next(this.value);
                case 'E':
                    return error(this.exception);
                case 'C':
                    return complete();
            }
        };

        Notification.prototype.accept = function accept(nextOrObserver, error, complete) {
            if (nextOrObserver && typeof nextOrObserver.next === 'function') {
                return this.observe(nextOrObserver);
            } else {
                return this['do'](nextOrObserver, error, complete);
            }
        };

        Notification.prototype.toObservable = function toObservable() {
            var kind = this.kind;
            var value = this.value;
            switch (kind) {
                case 'N':
                    return _Observable2['default'].of(value);
                case 'E':
                    return _Observable2['default']['throw'](value);
                case 'C':
                    return _Observable2['default'].empty();
            }
        };

        Notification.createNext = function createNext(value) {
            if (typeof value !== 'undefined') {
                return new Notification('N', value);
            }
            return this.undefinedValueNotification;
        };

        Notification.createError = function createError(err) {
            return new Notification('E', undefined, err);
        };

        Notification.createComplete = function createComplete() {
            return this.completeNotification;
        };

        return Notification;
    })();

    exports['default'] = Notification;

    Notification.completeNotification = new Notification('C');
    Notification.undefinedValueNotification = new Notification('N', undefined);
    module.exports = exports['default'];