2 import Promise from './promise';
4 export default function polyfill() {
7 if (typeof global !== 'undefined') {
9 } else if (typeof self !== 'undefined') {
13 local = Function('return this')();
15 throw new Error('polyfill failed because global object is unavailable in this environment');
19 let P = local.Promise;
22 var promiseToString = null;
24 promiseToString = Object.prototype.toString.call(P.resolve());
29 if (promiseToString === '[object Promise]' && !P.cast){
34 local.Promise = Promise;