"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

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; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

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



var Deferred = function () {
  function Deferred() {
    var _this = this;

    _classCallCheck(this, Deferred);

    this.settled = false;
    this.promise = new Promise(function (resolve, reject) {
      _this.resolve = resolve;
      _this.reject = reject;
    });
  }

  _createClass(Deferred, [{
    key: "getPromise",
    value: function getPromise() {
      return this.promise;
    }
  }, {
    key: "resolve",
    value: function resolve(value) {
      this.settled = true;
      this.resolve(value);
    }
  }, {
    key: "reject",
    value: function reject(reason) {
      this.settled = true;
      this.reject(reason);
    }
  }, {
    key: "catch",
    value: function _catch() {
      return Promise.prototype.catch.apply(this.promise, arguments);
    }
  }, {
    key: "then",
    value: function then() {
      return Promise.prototype.then.apply(this.promise, arguments);
    }
  }, {
    key: "done",
    value: function done() {
      Promise.prototype.done.apply(this.promise, arguments);
    }
  }, {
    key: "isSettled",
    value: function isSettled() {
      return this.settled;
    }
  }]);

  return Deferred;
}();

exports.default = Deferred;