resolves the last entry of this._iC
but only if the queue is empty
@return {Promise}
499740
function _tryIdleCall(idleQueue) {
    // ensure this does not run in parallel
    if (idleQueue._tryIR || idleQueue._iC.size === 0)
        return;
    idleQueue._tryIR = true;

    // w8 one tick
    setTimeout(() => {
        // check if queue empty
        if (!idleQueue.isIdle()) {
            idleQueue._tryIR = false;
            return;
        }

        /**
         * wait 1 tick here
         * because many functions do IO->CPU->IO
         * which means the queue is empty for a short time
         * but the ressource is not idle
         */
        setTimeout(() => {
            // check if queue still empty
            if (!idleQueue.isIdle()) {
                idleQueue._tryIR = false;
                return;
            }

            // ressource is idle
            _resolveOneIdleCall(idleQueue);
            idleQueue._tryIR = false;
        }, 0);
    }, 0);
}
931829
function() {
    var deferred = $q.defer();

    var current = $state.current();

    // Evaluate
    if(current) {
      var sources = (typeof current.load === 'string' ? [current.load] : current.load) || [];
      
      // Get promises
      $q.all(sources
        .map(function(src) {
          return _createLoadable(src);
        })
        .filter(function(loadable) {
          return !loadable.isComplete;
        })
        .map(function(loadable) {
          return loadable.promise;
        })
      )
          .then(function() {
            deferred.resolve();

          }, function(err) {
            $rootScope.$broadcast('$loadableError', err);
            deferred.reject(err);
          });

    // No state
    } else {
      deferred.resolve();
    }

    return deferred.promise;
  }
1214525
public final Optional<T> last() {
        // Iterables#getLast was inlined here so we don't have to throw/catch a NSEE
        Iterator<T> iterator = this.iterator();
        if (!iterator.hasNext()) {
            return empty();
        }

        while (true) {
            T current = iterator.next();
            if (!iterator.hasNext()) {
                return Optional.of(current);
            }
        }
    }
1056262
function lastRefreshInsertionPoint() {
                    var slotNext = refreshEnd;
                    while (!slotNext.firstInSequence) {
                        slotNext = slotNext.prev;

                        if (slotNext === refreshStart) {
                            return null;
                        }
                    }

                    return slotNext;
                }
983767
function resolveOrEnqueuePromise( PromiseInterface $promise, callable $resultCallback = null )
	{
		if ($this->next_async_request)
		{
			$promise = $promise->then(function($result) use ($resultCallback) {
				return $resultCallback ? $resultCallback($result) : null;
			});
			$this->next_async_request->setPromise($promise);
			return $this->next_async_request = null;
		}
		return $resultCallback ? $resultCallback($promise->wait()) : null;
	}
1189187
function() {
        this._completionDeferred = Promise.defer();

        // wrap in a promise so that if _startNextAuthStage
        // throws, it rejects the promise in a consistent way
        return Promise.resolve().then(() => {
            // if we have no flows, try a request (we'll have
            // just a session ID in _data if resuming)
            if (!this._data.flows) {
                this._doRequest(this._data);
            } else {
                this._startNextAuthStage();
            }
            return this._completionDeferred.promise;
        });
    }
187643
function queue(steps) {
  var swal = this;
  currentSteps = steps;

  var resetQueue = function resetQueue() {
    currentSteps = [];
    document.body.removeAttribute('data-swal2-queue-step');
  };

  var queueResult = [];
  return new Promise(function (resolve) {
    (function step(i, callback) {
      if (i < currentSteps.length) {
        document.body.setAttribute('data-swal2-queue-step', i);
        swal(currentSteps[i]).then(function (result) {
          if (typeof result.value !== 'undefined') {
            queueResult.push(result.value);
            step(i + 1, callback);
          } else {
            resetQueue();
            resolve({
              dismiss: result.dismiss
            });
          }
        });
      } else {
        resetQueue();
        resolve({
          value: queueResult
        });
      }
    })(0);
  });
}
652424
function () {
                    if (this._lastGroup && typeof this._lastGroup.index === "number") {
                        return Promise.wrap(this._count);
                    } else {
                        // Even if there's a current estimate for _count, consider this call to be a request to determine the true
                        // count.

                        var that = this;
                        var countPromise = new Promise(function (complete) {
                            var fetch = {
                                initialBatch: function () {
                                    that._fetchNextIndex();
                                },
                                getGroup: function () { return null; },
                                countBefore: 0,
                                countAfter: 0,
                                complete: function (failed) {
                                    if (failed) {
                                        that._count = 0;
                                    }

                                    var count = that._count;
                                    if (typeof count === "number") {
                                        complete(count);
                                        return true;
                                    } else {
                                        return false;
                                    }
                                }
                            };

                            that._fetchQueue.push(fetch);

                            if (!that._itemBatch) {
                                that._continueFetch(fetch);
                            }
                        });

                        return (typeof this._count === "number" ? Promise.wrap(this._count) : countPromise);
                    }
                }
447482
function () {

        $global.TaskPool = $prototype ({

            constructor: function (cfg) {
                            
                            this.maxTime        = cfg && cfg.maxTime
                            this.pending        = []

                            if (this.maxConcurrency = cfg && cfg.maxConcurrency) {
                                this.numActive = 0
                                this.queue     = [] } },

            run: function (task) { var self = this

                        if (this.numActive >= this.maxConcurrency) { // queue task

                            return new Promise (function (resolve) {
                                                    self.queue.push (function () {
                                                                        return self.run  (task)
                                                                                   .then (resolve) }) }) }
                        else { // execute task

                            var p = __(task)

                            if (this.maxTime !== undefined) {
                                p = p.timeout (this.maxTime) }

                            if (this.maxConcurrency !== undefined) { // if queueing, wait until complete and pop next task

                                                           self.numActive++
                                p = p.then (function (x) { self.numActive--

                                                   return (self.queue.length &&
                                                          (self.numActive < self.maxConcurrency))
                                                                          ? self.queue.shift () ().then (_.constant (x))
                                                                          : x }) }
                            this.pending.push (p)

                            return p } },


            all: $property (function () {
                                return Promise.all (this.pending) }) }) // @hide

     */

        __.scatter = function (x, fn, cfg /* { maxConcurrency, maxTime } */) {

                    return __.then (x, function (x) {

                        if (_.isStrictlyObject (x)) {

                            var result = _.coerceToEmpty (x),
                                tasks  = new TaskPool (cfg)

                            _.each2 (x, function (v, k) {
                                            tasks.run (fn.$ (v, k, x)).then (
                                                                        function (vk) {
                                                                            if (vk) {
                                                                                result[vk[1]] = vk[0] } }) })
                            return tasks.all.then (_.constant (result)) }

                        else {
                            return __(fn, x, undefined, x).then (function (vk) { return vk[0] }) } }) }
}
469199
function () {
        var that = this,
            fullQuery = that.extendedCurrentValue(),
            currentValue = that.el.val(),
            resolver = $.Deferred();

        resolver
            .done(function (suggestion) {
                that.selectSuggestion(suggestion, 0, currentValue, { hasBeenEnriched: true });
                that.el.trigger('suggestions-fixdata', suggestion);
            })
            .fail(function () {
                that.selection = null;
                that.el.trigger('suggestions-fixdata');
            });

        if (that.isQueryRequestable(fullQuery)) {
            that.currentValue = fullQuery;
            that.getSuggestions(fullQuery, { count: 1, from_bound: null, to_bound: null })
                .done(function (suggestions) {
                    // data fetched
                    var suggestion = suggestions[0];
                    if (suggestion) {
                        resolver.resolve(suggestion);
                    } else {
                        resolver.reject();
                    }
                })
                .fail(function () {
                    // no data fetched
                    resolver.reject();
                });
        } else {
            resolver.reject();
        }
    }
132074
public Entry getLast()
  {
    if (tc.isEntryEnabled())
    {
      SibTr.entry(tc, "getLast");     
      SibTr.exit(tc, "getLast", last);
    }

    return last;
  }
628892
function () {
	    	var deferred = $q.defer();
	    	var promise = deferred.promise;
            
            function ok(value){
                deferred.resolve(value);
            }
            
            function errorCallback(error){
                deferred.reject(new Error(error));
            }
            
            if($window.plugins){
                $window.plugins.appPreferences.show()
                    .then(ok, errorCallback);
            } else {
                deferred.reject(new Error(this.pluginNotEnabledMessage));
            }
	    	
	    	this.decoratePromise(promise);
	    	return promise;
	    }
1153785
function clearCache() {
      var defer = $q.defer();

      _checkImgCacheReady()
        .then(function() {
          ImgCache.clearCache(defer.resolve, defer.reject);
        })
        .catch(defer.reject);

      return defer.promise;
    }
43854
function (end, queue) {
            var self = this;
            util.each(self, function (elem) {
                Anim.pause(elem, queue);
            });
            return self;
        }
932420
function ( x ) {

		if ( Util.is.Error( x ) ) {
			return this.reject( x );
		}

		// Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
		try {

			if ( x === this ) {
				throw new TypeError('A promise cannot be resolved with itself.');
			}

			if ( Util.is.Promise( x ) || ( x !== null && Util.is.Object( x ) && Util.is.Function( x.then ) ) ) {
				Promise.doResolve( x.then.bind( x ), this.resolve, this.reject );
				return this;
			}

			if ( Util.is.Function( x ) ) {
				Promise.doResolve( x, this.resolve, this.reject );
				return this;
			}

			this.fulfill( x );

		} catch ( error ) {

			return this.reject( error );

		}

		return this;
	}
249004
function() {
      let undelivered = this.published.reset();
      if (undelivered.length > 0) {
        return Promise.map(undelivered, (message) => {
          return this.channel.publish(message);
        });
      }
      return Promise.resolve(true);
    }
1080594
function resolveAll () {
    // get data column to decode data
    var dataColumn = this.query.model.columnName('data')
    // skip if no data column
    if (!defined(dataColumn) || !defined(this.result[dataColumn])) {
        return
    }
    // get data
    var data = this.result[dataColumn]
    // iterate over properties resolving any models
    return Promise.map(_.keys(data), property => {
        return this.resolveProperty(data, property)
    }, {
        concurrency: this.query.model.concurrency,
    })
    // discard map result
    .then(() => undefined)
}