import _Promise from "babel-runtime/core-js/promise";
/**
 * Chain promises so that they are evaluated in order.
 * @returns {object} - The promise queue object.
 */
var PromiseQueue = function PromiseQueue() {
  var promise = _Promise.resolve();

  return {
    push: function push(fn) {
      promise = promise.then(fn, fn);
    },
    fetch: function fetch(fn) {
      var returnResolver = void 0;
      var returnRejecter = void 0;
      var returnPromise = new _Promise(function (resolve, reject) {
        returnResolver = resolve;
        returnRejecter = reject;
      });
      promise = promise.then(fn, fn).then(function (res) {
        return returnResolver(res);
      }, function (err) {
        return returnRejecter(err);
      });

      return returnPromise;
    }
  };
};

export default PromiseQueue;
//# sourceMappingURL=PromiseQueue.js.map