Promise resolver callback generator
@param callable|null $onFulfilled
@param callable|null $onRejected
@param callable|null $onProgress
@return \Closure
425242
protected function resolver(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null)
    {
        return function ($resolve, $reject, $notify) use ($onFulfilled, $onRejected, $onProgress) {
            if ($onProgress) {
                $progressHandler = function ($update) use ($notify, $onProgress) {
                    try {
                        $notify($onProgress($update), $this->sharedData);
                    } catch (\Throwable $e) {
                        $notify($e, $this->sharedData);
                    }
                };
            } else {
                $progressHandler = $notify;
            }

            $this->handlers[] = function (ExtendedPromiseInterface $promise) use ($onFulfilled, $onRejected, $resolve, $reject, $progressHandler) {
                $promise
                    ->then($onFulfilled, $onRejected)
                    ->done($resolve, $reject, $progressHandler);
            };

            $this->progressHandlers[] = $progressHandler;
        };
    }
995452
function Promise(resolver) {
  if (!(this instanceof Promise)) {
    throw new TypeError('Constructor Promise requires `new`');
  }
  if (!isFunction(resolver)) {
    throw new TypeError('Must pass resolver function');
  }

  /**
   * @type {function(this:Promise,*=,function(*=),function(*=),Deferred):!Promise}
   * @private
   */
  this._state = PendingPromise;

  /**
   * @type {*}
   * @private
   */
  this._value = [];

  /**
   * @type {boolean}
   * @private
   */
  this._isChainEnd = true;

  doResolve(
    this,
    adopter(this, FulfilledPromise),
    adopter(this, RejectedPromise),
    { then: resolver }
  );
}
379780
function fulfilled(value) {
            var p = new Promise();
            p.then = then;
            states.fulfill(p, value);
            return p;

            function then(onFulfilled) {
                try {
                    return resolve(typeof onFulfilled == 'function' ? onFulfilled(value) : value);
                } catch (e) {
                    return rejected(e);
                }
            }
        }
321802
function resolver(obj) {
  return new Promise(function(resolve, reject) {
    _.isEmpty(obj.results) ? reject(new Error(JSON.stringify(obj.errors))) : resolve(obj.results);
  })
}
72557
function fulfillPromise(promise, value) {
  if (promise.state !== PENDING) {return;}

  setValue(promise, value);
  setState(promise, UNFULFILLED);

  setImmediate(function() {
    setState(promise, FULFILLED);
    invokeFunctions(promise);
  });
}
469273
function resolve(promise) {
    var method = promise.state === FULFILLED ? 'onFulfilled' : 'onRejected';
    var arg = method === 'onFulfilled' ? promise.value : promise.reason;
    var handler, value;

    nextTick(function() {
      var isPromise;

      while (promise.handlers[0]) {
        handler = promise.handlers.shift();

        try {
          value = handler[method](arg);

          // Handle "thenables" as well as Promises
          isPromise = value instanceof Promise || value && isFunc(value.then);

          if (isPromise) {
            value.then(function(value) { fulfill(handler.promise, value); },
                       function(reason) { reject(handler.promise, reason); });
          } else {
            fulfill(handler.promise, value);
          }
        } catch(err) {
          reject(handler.promise, err);
        }
      }
    });

    return promise;
  }
555381
function then(onFulfilled, onRejected) {
      var state = getInternalPromiseState(this);
      var reaction = newPromiseCapability(speciesConstructor(this, PromiseConstructor));
      reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
      reaction.fail = typeof onRejected == 'function' && onRejected;
      reaction.domain = IS_NODE ? process.domain : undefined;
      state.parent = true;
      state.reactions.push(reaction);
      if (state.state != PENDING) notify(this, state, false);
      return reaction.promise;
    }
144121
function getPromise(provider, extension) {
			var contentTypeIds = provider.getProperty("contentType") || provider.getProperty("contentTypes"), //$NON-NLS-1$ //$NON-NLS-0$
			    fileTypes = provider.getProperty("fileTypes"); // backwards compatibility //$NON-NLS-0$
			if (contentTypeIds) {
				return Deferred.when(contentTypeService.isSomeExtensionOf(contentType, contentTypeIds)).then(
					function (isMatch) {
						return isMatch ? provider : null;
					});
			} else if (extension && fileTypes && fileTypes.indexOf(extension) !== -1) {
				var d = new Deferred();
				d.resolve(provider);
				return d;
			}
			return null;
		}
1215758
public static function create(&$resolve = null, &$reject = null, callable $canceller = null)
    {
        $deferred = new Deferred($canceller);

        $reject = [$deferred, 'reject'];
        $resolve = [$deferred, 'resolve'];

        return $deferred->promise();
    }
986268
function then(onFulfilled, onRejected) {
      var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
      reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
      reaction.fail = typeof onRejected == 'function' && onRejected;
      reaction.domain = isNode ? process.domain : undefined;
      this._c.push(reaction);
      if (this._a) this._a.push(reaction);
      if (this._s) notify(this, false);
      return reaction.promise;
    }
1203956
function (web3Provider, result) {
    return new Promise(function (onResolve, onReject) {
      onResolve(web3Provider.utils.hexToNumber(result));
    });
  }
337785
function(executor) {
            /*  optionally support non-constructor/plain-function call  */
            if (!(this instanceof Promise)) return new Promise(executor);
            /*  initialize object  */
            this.id = "Thenable/1.0.7";
            this.state = STATE_PENDING;
            /*  initial state  */
            this.fulfillValue = undefined;
            /*  initial value  */
            /*  [Promises/A+ 1.3, 2.1.2.2]  */
            this.rejectReason = undefined;
            /*  initial reason */
            /*  [Promises/A+ 1.5, 2.1.3.2]  */
            this.onFulfilled = [];
            /*  initial handlers  */
            this.onRejected = [];
            /*  initial handlers  */
            /*  support optional executor function  */
            if (typeof executor === "function") executor.call(this, this.fulfill.bind(this), this.reject.bind(this));
        }
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();
        }
    }
941605
function makePromise(requestInstance, promiseFactoryFn) {

  // Resolver function wich assigns the promise (resolve, reject) functions
  // to the requestInstance
  function Resolver(resolve, reject) {
    this._resolve = resolve;
    this._reject = reject;
  }

  return promiseFactoryFn(Resolver.bind(requestInstance));
}
920272
function addHandler (p1, p2, onFulfilled, onRejected) {
        // 2.2.1
        if (isFunction(onFulfilled))
            p2._onFulfilled = onFulfilled;
        if (isFunction(onRejected)) {
            if (p1[$unhandled]) emitEvent($rejectionHandled, p1);

            p2._onRejected = onRejected;
        }

        p1[p1._pCount++] = p2;

        // 2.2.6
        if (p1._s !== $pending)
            scheduleHandler(p1, p2);

        // 2.2.7
        return p2;
    }
106071
function doResolve(result) {
  let self = this;
  if (result === self) {
    // Promise Standard 2.3.1
    return doReject.call(
      self,
      new TypeError("Can not resolve 'Promise' itself")
    );
  }
  // Promise Standard 2.3.3.2
  try {
    // Promise Standard 2.3.2 and 2.3.3 can be merge
    // if result is a thenable(.then)
    let then = safelyToThen(result);
    if (then) {
      // Promise Standard 2.3.3.3
      safelyToExecutor(self, then.bind(result));
    } else {
      // [[ async ]]
      setTimeout(function() {
        // commonly case
        if (self.currentState === Shared.PENDING) {
          self.currentState = Shared.FULFILLED;
          self.valOrErr = result;
          for (let i = 0; i < self.onFulfilledCallback.length; i++) {
            self.onFulfilledCallback[i](result);
          }
          self.onFulfilledCallback = [];
        }
      }, 0);
    }
    // case: when then(doResolve, doReject) -> asyncToResolveOrReject -> func(arg) -> return self
    return self;
  } catch (error) {
    return doReject.call(self, error);
  }
}
1042359
function Promise(resolver) {
  if (!(this instanceof InstrumentedPromise)) {
    throw new TypeError('Cannot call a class as a function');
  }
  const promise = new OriginalPromise((resolve, reject) =>
    resolver(resolve, arg => {
      OriginalPromise.resolve().then(() => {
        if (promise._hasDownstreams === undefined) {
          dispatchUnhandledRejectionEvent(promise, arg);
        }
      });
      return reject(arg);
    }));
  promise.__proto__ = InstrumentedPromise.prototype;
  return promise;
}