# Code coverage report for RxJS/dist/cjs/operators/sample.js

## Statements: 94.23% (49 / 52) Branches: 66.67% (12 / 18) Functions: 93.75% (15 / 16) Lines: 97.73% (43 / 44) Ignored: none

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

    1
    1

    1

    2

    27

    1

    1

    1
    9

    1
    1
    9

    9

    1
    9

    1

    1
    1

    1
    9

    9
    9
    9
    9

    1
    23
    23

    1
    9
    7

    1

    1
    1

    1
    9

    9
    9

    1
    9

    1

    1

    1

    1'use strict';

    exports.__esModule = true;
    exports['default'] = sample;

    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 _Subscriber3 = require('../Subscriber');

    var _Subscriber4 = _interopRequireDefault(_Subscriber3);

    function sample(notifier) {
        return this.lift(new SampleOperator(notifier));
    }

    var SampleOperator = (function () {
        function SampleOperator(notifier) {
            _classCallCheck(this, SampleOperator);

            this.notifier = notifier;
        }

        SampleOperator.prototype.call = function call(subscriber) {
            return new SampleSubscriber(subscriber, this.notifier);
        };

        return SampleOperator;
    })();

    var SampleSubscriber = (function (_Subscriber) {
        _inherits(SampleSubscriber, _Subscriber);

        function SampleSubscriber(destination, notifier) {
            _classCallCheck(this, SampleSubscriber);

            _Subscriber.call(this, destination);
            this.notifier = notifier;
            this.hasValue = false;
            this.add(notifier._subscribe(new SampleNoficationSubscriber(this)));
        }

        SampleSubscriber.prototype._next = function _next(value) {
            this.lastValue = value;
            this.hasValue = true;
        };

        SampleSubscriber.prototype.notifyNext = function notifyNext() {
            if (this.hasValue) {
                this.destination.next(this.lastValue);
            }
        };

        return SampleSubscriber;
    })(_Subscriber4['default']);

    var SampleNoficationSubscriber = (function (_Subscriber2) {
        _inherits(SampleNoficationSubscriber, _Subscriber2);

        function SampleNoficationSubscriber(parent) {
            _classCallCheck(this, SampleNoficationSubscriber);

            _Subscriber2.call(this, null);
            this.parent = parent;
        }

        SampleNoficationSubscriber.prototype._next = function _next() {
            this.parent.notifyNext();
        };

        SampleNoficationSubscriber.prototype._error = function _error(err) {
            this.parent.error(err);
        };

        SampleNoficationSubscriber.prototype._complete = function _complete() {
            //noop
        };

        return SampleNoficationSubscriber;
    })(_Subscriber4['default']);

    module.exports = exports['default'];