Rejects the promise chain if this behavior is already disposed.
@return {jQuery.Promise} that is resolved if the behavior is not disposed and rejects if the behavior is disposed.
@private
766454
function() {
      var resultDeferred = $.Deferred();
      if (this.isDisposed()) {
        var rejectArguments = Array.prototype.slice.call(arguments);
        rejectArguments.push('Data Behavior disposed, aborting.');
        resultDeferred.reject.apply(resultDeferred, rejectArguments);
      } else {
        resultDeferred.resolve.apply(resultDeferred, arguments);
      }
      return resultDeferred.promise();
    }
463338
function () {
		//check if we are able to execute
		if (!canExecuteWrapper.call(options.context || this)) {
			//dont attach any global handlers
			return instantDeferred(false, null, options.context || this).promise();
		}

		//notify that we are running and clear any existing error message
		isRunning(true);
		failed(false);
		failMessage('');

		//try to invoke the action and get a reference to the deferred object
		var promise;
		try {
			promise = options.action.apply(options.context || this, arguments);

			//if the returned result is *not* a promise, create a new one that is already resolved
			if (!isPromise(promise)) {
				promise = instantDeferred(true, promise, options.context || this).promise();
			}

		} catch (error) {
			promise = instantDeferred(false, error, options.context || this).promise();
		}

		//set up our callbacks
		callbacks.always.forEach(function(callback) {
			promise.then(callback, callback);
		});
		callbacks.fail.forEach(function(callback) {
			promise.then(null, callback);
		});
		callbacks.done.forEach(function(callback) {
			promise.then(callback);
		});

		return promise;
	}
35223
function (promises) {
            var count = promises.length;
            if (!count) {
                return null;
            }
            var defer = new Defer();
            for (var i = 0; i < promises.length; i++) {
                /*jshint loopfunc:true*/
                (function (promise, i) {
                    when(promise, function (value) {
                        promises[i] = value;
                        if (--count === 0) {
                            // if all is resolved
                            // then resolve final returned promise with all value
                            defer.resolve(promises);
                        }
                    }, function (r) {
                        // if any one is rejected
                        // then reject final return promise with first reason
                        defer.reject(r);
                    });
                }(promises[i], i));
            }
            return defer.promise;
        }
1059917
function toReject() {
  return {
    compare(actual) {
      assertPromise(actual);
      const failure = jasmine.createSpy('Promise failure callback');
      actual.then(angular.noop, failure);
      createScope().$digest();
      const pass = isJasmine2 ? failure.calls.any() : failure.calls.length > 0;

      return getResult('toReject', pass, 'Expected promise {not} to have been rejected');
    }
  };
}
1192355
function() {
                        var args = Array.prototype.slice.call(arguments, 0);
                        deferredObject.reject.apply(null, ctxArgs.concat(args));
                    }
849783
function(error) {
      if (this._resolved || this._rejected) {
        throw "A promise was rejected even though it had already been " +
          (this._resolved ? "resolved" : "rejected") + ".";
      }
      this._rejected = true;
      this._error = error;
      Parse._arrayEach(this._rejectedCallbacks, function(rejectedCallback) {
        rejectedCallback(error);
      });
      this._resolvedCallbacks = [];
      this._rejectedCallbacks = [];
    }
1306918
function promiseWhen(promise, fulfilled, rejected) {
        // simply call rejected
        if (promise instanceof Reject) {
            // if there is a rejected , should always has! see when()
            rejected.call(promise, promise[PROMISE_VALUE]);
        } else {
            var v = promise[PROMISE_VALUE], pendings = promise[PROMISE_PENDINGS];
            if (pendings === undefined) {
                pendings = promise[PROMISE_PENDINGS] = [];
            }    // unresolved
                 // pushed to pending list
            // unresolved
            // pushed to pending list
            if (pendings) {
                pendings.push([
                    fulfilled,
                    rejected
                ]);
            } else if (isPromise(v)) {
                // rejected or nested promise
                promiseWhen(v, fulfilled, rejected);
            } else {
                // fulfilled value
                // normal value represents ok
                // need return user's return value
                // if return promise then forward
                if (fulfilled) {
                    fulfilled.call(promise, v);
                }
            }
        }
    }
580858
function _singlePromise () {
  let  done, cancel;
  const x = new Promise ( (resolve, reject ) => { 
                                                  done   = resolve
                                                  cancel = reject
                                 })

   return { 
               promise    : x
             , done       : done 
             , cancel     : cancel
             , onComplete : _after(x)
           }
   }
306154
function (callback) {
        return new Promise((resolve, reject) => {
          this.end(result => {
            try {
              resolve(callback(result))
            } catch (err) {
              reject(err)
            }
          })
        })
      }
1057595
function(event){
			var self = this,
				deferred = $.Deferred();

			if(self.beforeClose(event) === false) {
				deferred.reject();
			} else {

				if (0 === pruneOpened(self).length) {
					toggleGlobalEvents(false);
				}

				self.$instance.fadeOut(self.closeSpeed,function(){
					self.$instance.detach();
					self.afterClose(event);
					deferred.resolve();
				});
			}
			return deferred.promise();
		}
106902
function() {
				var prom = new promise.Promise();
				//console.log("deep2.Deffered.promise : ", prom, " r,r,c : ", this.rejected, this.resolved, this.canceled)
				if (this.resolved)
					return prom.resolve(this._success);
				if (this.rejected)
					return prom.reject(this._error);
				this._promises.push(prom);
				return prom;
			}
367587
function(javascript) {
    try {
      return Promise.resolve({
        input: javascript,
        output: eval(javascript),
        exception: null
      });
    }
    catch (ex) {
      return Promise.resolve({
        input: javascript,
        output: null,
        exception: ex
      });
    }
  }
59427
function () {
            this.__ending = true;
            var conn, fQueue = this.__freeObjects, count = this.count, ps = [];
            while ((conn = this.__freeObjects.dequeue()) !== undefined) {
                ps.push(this.closeConnection(conn));
            }
            var inUse = this.__inUseObjects;
            for (var i = inUse.length - 1; i >= 0; i--) {
                ps.push(this.closeConnection(inUse[i]));
            }
            this.__inUseObjects.length = 0;
            return new PromiseList(ps).promise();
        }
27499
function () {
            var self = this;
            if (this._dirty) {
                self._dirty = false;
                return this.storage.save(this.data);
            } else {
                return (new $.Deferred()).resolve().promise();
            }
        }
1135075
function(argument) {
				//  console.log("DeepDeferred.reject");
				if (this.rejected || this.resolved)
					throw new Error("deferred has already been ended !");
				this._error = argument;
				this.rejected = true;
				var self = this;
				this._promises.forEach(function(promise) {
					promise.reject(argument);
				});
			}
1164073
def rejected(reason):
        """"""
        p = Promise()
        p._state = 'rejected'
        p.reason = reason
        return p
110940
function chain(promise,
               onResolve = idResolveHandler,
               onReject = idRejectHandler) {
  var deferred = getDeferred(promise.constructor);
  switch (promise.status_) {
    case undefined:
      throw TypeError;
    case 0:
      promise.onResolve_.push(onResolve, deferred);
      promise.onReject_.push(onReject, deferred);
      break;
    case +1:
      promiseEnqueue(promise.value_, [onResolve, deferred]);
      break;
    case -1:
      promiseEnqueue(promise.value_, [onReject, deferred]);
      break;
  }
  return deferred.promise;
}