import Promise from './index';
import promiseFinally from './finally';
import allSettled from './allSettled';

/** @suppress {undefinedVars} */
var globalNS = (function() {
  // the only reliable means to get the global object is
  // `Function('return this')()`
  // However, this causes CSP violations in Chrome apps.
  if (typeof self !== 'undefined') {
    return self;
  }
  if (typeof window !== 'undefined') {
    return window;
  }
  if (typeof global !== 'undefined') {
    return global;
  }
  throw new Error('unable to locate global object');
})();

// Expose the polyfill if Promise is undefined or set to a
// non-function value. The latter can be due to a named HTMLElement
// being exposed by browsers for legacy reasons.
// https://github.com/taylorhakes/promise-polyfill/issues/114
if (typeof globalNS['Promise'] !== 'function') {
  globalNS['Promise'] = Promise;
} else {
  if (!globalNS.Promise.prototype['finally']) {
    globalNS.Promise.prototype['finally'] = promiseFinally;
  } 
  if (!globalNS.Promise.allSettled) {
    globalNS.Promise.allSettled = allSettled;
  }
}

@@ -882,20 +882,16 @@
 %0A%7D else 
-%7B%0A  
 if (!glo
@@ -924,26 +924,24 @@
 inally'%5D) %7B%0A
-  
   globalNS.P
@@ -990,14 +990,14 @@
 ly;%0A
-  %7D %0A 
+%7D else
  if 
@@ -1029,18 +1029,16 @@
 tled) %7B%0A
-  
   global
@@ -1073,14 +1073,10 @@
 ettled;%0A
-  %7D%0A
 %7D%0A

Revert "Bugfix: `allSettled` is not registered when `finally` is missing (#127)"