# Code coverage report for modules/Disposable.js

## Statements: 93.94% (31 / 33) Branches: 64.29% (9 / 14) Functions: 100% (8 / 8) Lines: 100% (17 / 17) Ignored: none

All files » modules/ » Disposable.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

    52

    1

    1
    1

    1
    1
    52

    52
    52

    1
    34
    30
    30

    1

    1

    1
    1
     "use strict";

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

    var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; Eif ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { Iif (protoProps) defineProperties(Constructor.prototype, protoProps); Eif (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

    exports.__esModule = true;
    var noop = function noop() {};

    /**
     * The basic disposable.
     */

    var Disposable = (function () {
      function Disposable(action) {
        _classCallCheck(this, Disposable);

        this.isDisposed = false;
        this.action = action || noop;
      }

      Disposable.prototype.dispose = function dispose() {
        if (!this.isDisposed) {
          this.action.call(null);
          this.isDisposed = true;
        }
      };

      _createClass(Disposable, null, [{
        key: "empty",
        enumerable: true,
        value: { dispose: noop }
      }]);

      return Disposable;
    })();

    exports["default"] = Disposable;
    module.exports = exports["default"];
    //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9kYW4vRG9jdW1lbnRzL1Byb2plY3RzL2Rpc3Bvc2FibGVzL21vZHVsZXMvRGlzcG9zYWJsZS5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBQUEsSUFBTSxJQUFJLEdB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