Rejects deferred promises.

@param {Object[]} batch Batch request data.
@param {XMLHttpRequest} xhr
437140
function (batch, xhr) {
                for (var i = 0, requestId; i < batch.length; i++) {
                    requestId = this._getRequestId(batch[i].method, batch[i].params);
                    this._rejectPromise(this._deferreds[requestId], xhr);
                    delete this._deferreds[requestId];
                }
            }
298880
function handleBatchRequest(unused1, unused2, data) {
  const requests = data.requests;
  const getResults = requests.map(request => {
    const method = request.method;
    const path = request.path;
    const body = request.body;
    return handleRequest(method, path, body)
      .then(result => Parse.Promise.as({ success: result.response }));
  });

  return Parse.Promise.when.apply(null, getResults).then(function theResults() {
    return respond(200, arguments);
  });
}
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 = [];
    }
1253098
function checkPromise(index) {
      var res = cb(callbacks[index]); // actually calling callback
      if (res instanceof Promise) {
        res.then(function (cbRes) {
          if (cbRes !== false) {
            // keep going
            if (index > 0) {
              checkPromise(index - 1);
            }
          }
        });
      } else {
        if (res !== false) {
          // keep going
          if (index > 0) {
            checkPromise(index - 1);
          }
        }
      }
    }
1014930
function handleMongoWriteConcernError(batch, bulkResult, ordered, err, callback) {
  mergeBatchResults(ordered, batch, bulkResult, null, err.result);

  const wrappedWriteConcernError = new WriteConcernError({
    errmsg: err.result.writeConcernError.errmsg,
    code: err.result.writeConcernError.result
  });
  return handleCallback(
    callback,
    new BulkWriteError(toError(wrappedWriteConcernError), new BulkWriteResult(bulkResult)),
    null
  );
}
210074
def submitBatches(self, batches):
    
    self._seqid += 1
    future = self._reqs[self._seqid] = concurrent.Future()
    self.send_submitBatches(batches)
    return future
541296
function rejectPromise(promise, value) {
  if (promise.state !== PENDING) {return;}

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

  setImmediate(function() {
    setState(promise, FAILED);
    invokeFunctions(promise);
  });
}
1273708
function BatchRequest(env, batchParams, key) {
	ApiRequest.call(this, env);
	this.queueKey = key;
	this.batchParams = batchParams;
	this.reqType = 'Batch request';

	this.batchText = JSON.stringify(batchParams);
	var apiargs = {
		format: 'json',
		formatversion: 2,
		action: 'parsoid-batch',
		batch: this.batchText,
	};

	this.requestOptions = {
		method: 'POST',
		followRedirect: true,
		uri: env.conf.wiki.apiURI,
		timeout: env.conf.parsoid.timeouts.mwApi.batch,
	};

	// Use multipart form encoding to get more efficient transfer if the gain
	// will be larger than the typical overhead.
	if (encodeURIComponent(apiargs.batch).length - apiargs.batch.length > 600) {
		this.requestOptions.formData = apiargs;
	} else {
		this.requestOptions.form = apiargs;
	}

	this.request(this.requestOptions);
}
1025528
function(xhr, o) {
		var opts = o || {};
		
		if (xhr) {
			opts.quiet && (xhr.quiet = true);
			if (opts.abort && xhr._requestId) {
				this.request({
					data: {
						cmd: 'abort',
						id: xhr._requestId
					},
					preventDefault: true
				});
			}
			xhr.abort();
			xhr = void 0;
		}
	}
394411
function(method, data, callback) {
      xhr.open(method, url, true, user, password);
      if (mimeType != null && !headers.has("accept")) headers.set("accept", mimeType + ",*/*");
      if (xhr.setRequestHeader) headers.each(function(value, name) { xhr.setRequestHeader(name, value); });
      if (mimeType != null && xhr.overrideMimeType) xhr.overrideMimeType(mimeType);
      if (responseType != null) xhr.responseType = responseType;
      if (timeout > 0) xhr.timeout = timeout;
      if (callback == null && typeof data === "function") callback = data, data = null;
      if (callback != null && callback.length === 1) callback = fixCallback(callback);
      if (callback != null) request.on("error", callback).on("load", function(xhr) { callback(null, xhr); });
      event.call("beforesend", request, xhr);
      xhr.send(data == null ? null : data);
      return request;
    }
1312305
function Promise () {
	this.deferred = false;
	this.handlers = [];
	this.state    = promise.state.PENDING;
	this.value    = null;
}
390055
function prettifyBatches(batches) {
    return Promise.all(batches.map(({ files, config }) => prettifyFiles(files, config)));
}
1284986
function asyncBatch (
  renderer,
  pushable,
  resolve,
  reject
) {
  const pull = pullBatch(renderer, pushable);

  pull.then(result => {
    if (result === EXHAUSTED) {
      resolve();
    } else {
      setImmediate(
        asyncBatch,
        renderer,
        pushable,
        resolve,
        reject,
      );
    }
  }).catch(err => {
    reject(err);
  });
}
254793
private void awaitRequestsCompletion() throws IOException {
    // Don't wait until all requests will be completed if enough requests are pending for full batch
    while (!responseFutures.isEmpty() && pendingRequests.size() < maxRequestsPerBatch) {
      try {
        responseFutures.remove().get();
      } catch (InterruptedException | ExecutionException e) {
        if (e.getCause() instanceof IOException) {
          throw (IOException) e.getCause();
        }
        throw new RuntimeException("Failed to execute batch", e);
      }
    }
  }
54614
function (nodes, batchOps, done) {
      self.db.batch(batchOps, function (err) {
        if (err) {
          nodes.forEach(rejectNode)
          return done(err)
        }
        done(null, nodes)
      })
    }
227565
function renderBatch(batch) {
  // Localize batch info
  var description = batch.nodeName,
      value = batch.value,
      childNodes = batch.childNodes,
      fns;

  // If there are no children, we are on a leaf
  if (!childNodes) {
    // If the value is an array, run all of them in series
    if (Array.isArray(value)) {
      fns = value;
      // TODO: Conditionally require a callback
      it(description, function handleMultipleIts (done) {
        // Iterate the functions in order
        var that = this;
        async.forEachSeries(fns, function (fn, cb) {
          // Clear the timeout
          that.runnable().resetTimeout();

          // If the function is async, pass it a callback
          if (fn.length) {
            fn.call(that, cb);
          } else{
          // Otherwise, run it and call the callback
            fn.call(that);
            cb(null);
          }
        }, done);
      });
    } else {
    // Otherwise, describe and execute `it`
      it(description, value);
    }
  } else {
  // Otherwise, we are on a parent node
    // Describe this context
    describe(description, function execRecursiveRender () {
      // If there is a value, act on it
      if (value) {
        // If the value is not an object, upcast them to an object
        var valObj = value;
        if (typeof value !== 'object' || Array.isArray(value)) {
          valObj = {before: value};
        }

        // Run all the hooks that exist
        // DEV: In all cases, `mocha` will handle the async and sync timings =3
        if (valObj.before) { addHooks(before, valObj.before); }
        if (valObj.beforeEach) { addHooks(beforeEach, valObj.beforeEach); }
        if (valObj.afterEach) { addHooks(afterEach, valObj.afterEach); }
        if (valObj.after) { addHooks(after, valObj.after); }
      }

      // Execute each of the children
      childNodes.forEach(renderBatch, this);
    });
  }
}
431215
function (methodName, params, execOptions) {
                var defer = vow.defer();
                var url = this._basePath + methodName;
                var data = JSON.stringify(params);

                sendAjaxRequest(url, data, execOptions).then(
                    this._resolvePromise.bind(this, defer),
                    this._rejectPromise.bind(this, defer)
                );

                return defer.promise();
            }