function NativePromiseWrapper(resolve, reject) {
  return new window.Promise(resolve, reject);
}

function InboxAPI(optionsOrAPIUrl, optionalPromiseConstructor) {
  var options;

  if (optionsOrAPIUrl && typeof optionsOrAPIUrl === 'object') {
    options = optionsOrAPIUrl;
  } else {
    options = {
      url: optionsOrAPIUrl,
      promise: optionalPromiseConstructor || window.Promise
    };
  }

  if (options.url == null) {
    throw new TypeError("Unable to construct 'InboxAPI': missing option `url`");
  } else if (typeof options.url !== 'string') {
    throw new TypeError("Unable to construct 'InboxAPI': option `url` must be a string");
  }

  if (options.promise == null) {
    throw new TypeError("Unable to construct 'InboxAPI': missing option `promise`, " +
                        "or no native Promise available");    
  } else if (typeof options.promise !== 'function') {
    throw new TypeError("Unable to construct 'InboxAPI': option `promise` must be a " +
                        "function which returns an ECMAScript6-compatible Promise");
  }

  if (options.promise === window.Promise) {
    options.promise = NativePromiseWrapper;
  }

  if (!(this instanceof Inbox)) {
    return new Inbox(options);
  }

  options._cache = {};

  this._ = options;
  DefineProperty(this, '_', INVISIBLE);
}

@@ -639,32 +639,108 @@
  string%22);%0A  %7D%0A%0A
+  if (options.promise == null) %7B%0A    options.promise = window.Promise;%0A  %7D%0A%0A
   if (options.pr
@@ -905,21 +905,14 @@
 e%22);
-    %0A  %7D else
+%0A  %7D%0A 
  if 
@@ -1253,16 +1253,19 @@
 of Inbox
+API
 )) %7B%0A   
@@ -1281,16 +1281,19 @@
 ew Inbox
+API
 (options

fix error handling and avoid ReferenceError