index.js
function doit(originalArgs, originalSettings, jqOptions, bjOptions) {
    var xhr;
    var p = new Promise(function resolver(resolve, reject) {
      xhr = bluetry.perform.call(this, originalSettings, jqOptions, bjOptions);
      function succeded(data, textStatus, jqXHR) {
        resolve(bjOptions.verboseResults ? [data, textStatus, jqXHR] : data);
      }

      function failed(jqXHR, textStatus, errorThrown) {
        var error = makeError(
          jqXHR, textStatus, errorThrown,
          bjOptions.verboseExceptions ? originalArgs : null);

        if (!isNetworkIssue(error)) {
          // As mentioned earlier, errors that are not due to the network cause
          // an immediate rejection: no diagnosis.
          reject(error);
        }
        else {
          // Move to perhaps diagnosing what could be the problem.
          var diagnose = bjOptions.diagnose;
          if (!diagnose || !diagnose.on) {
            // The user did not request diagnosis: fail now.
            reject(error);
          }
          else {
            // Otherwise, we perform the requested diagnosis.  We cannot just
            // call ``reject`` with the return value of ``diagnoseIt``, as the
            // rejection value would be a promise and not an error. (``resolve``
            // assimilates promises, ``reject`` does not).
            resolve(diagnoseIt(error, diagnose));
          }
        }
      }

      xhr.fail(failed).done(succeded);
    });

    return { xhr: xhr, promise: p };
  }
function doit(originalArgs, originalSettings, jqOptions, bjOptions) {
    var xhr;
    var p = new Promise(function resolver(resolve, reject) {
      xhr = bluetry.perform.call(this, originalSettings, jqOptions, bjOptions);
      function succeded(data, textStatus, jqXHR) {
        resolve(bjOptions.verboseResults ? [data, textStatus, jqXHR] : data);
      }

      function failed(jqXHR, textStatus, errorThrown) {
        var error = makeError(
          jqXHR, textStatus, errorThrown,
          bjOptions.verboseExceptions ? originalArgs : null);

        if (!isNetworkIssue(error)) {
          // As mentioned earlier, errors that are not due to the network cause
          // an immediate rejection: no diagnosis.
          reject(error);
        }
        else {
          // Move to perhaps diagnosing what could be the problem.
          var diagnose = bjOptions.diagnose;
          if (!diagnose || !diagnose.on) {
            // The user did not request diagnosis: fail now.
            reject(error);
          }
          else {
            // Otherwise, we perform the requested diagnosis.  We cannot just
            // call ``reject`` with the return value of ``diagnoseIt``, as the
            // rejection value would be a promise and not an error. (``resolve``
            // assimilates promises, ``reject`` does not).
            resolve(diagnoseIt(error, diagnose));
          }
        }
      }

      xhr.fail(failed).done(succeded);
    });

    return { xhr: xhr, promise: p };
  }
function doit ( originalArgs , originalSettings , jqOptions , bjOptions ) { var xhr ; var p = new Promise ( function resolver ( resolve , reject ) { xhr = bluetry . perform . call ( this , originalSettings , jqOptions , bjOptions ) ; function succeded ( data , textStatus , jqXHR ) { resolve ( bjOptions . verboseResults ? [ data , textStatus , jqXHR ] : data ) ; } function failed ( jqXHR , textStatus , errorThrown ) { var error = makeError ( jqXHR , textStatus , errorThrown , bjOptions . verboseExceptions ? originalArgs : null ) ; if ( ! isNetworkIssue ( error ) ) { // As mentioned earlier, errors that are not due to the network cause // an immediate rejection: no diagnosis. reject ( error ) ; } else { // Move to perhaps diagnosing what could be the problem. var diagnose = bjOptions . diagnose ; if ( ! diagnose || ! diagnose . on ) { // The user did not request diagnosis: fail now. reject ( error ) ; } else { // Otherwise, we perform the requested diagnosis.  We cannot just // call ``reject`` with the return value of ``diagnoseIt``, as the // rejection value would be a promise and not an error. (``resolve`` // assimilates promises, ``reject`` does not). resolve ( diagnoseIt ( error , diagnose ) ) ; } } } xhr . fail ( failed ) . done ( succeded ) ; } ) ; return { xhr : xhr , promise : p } ; }
This is the core of the functionality provided by Bluejax.
This is the core of the functionality provided by Bluejax .