Urara-Blog/node_modules/.pnpm-store/v3/files/ec/adba77a0da56eb979bd5674ae2bb81801e8eeb61cc6bdfc68a65057909687905b25d3a6beeda1de18031769af091abf7f3a88bab1f60a490344b37b4835a7b
2022-08-14 01:14:53 +08:00

35 lines
748 B
Text

/*global self*/
import Promise from './promise';
export default function polyfill() {
let local;
if (typeof global !== 'undefined') {
local = global;
} else if (typeof self !== 'undefined') {
local = self;
} else {
try {
local = Function('return this')();
} catch (e) {
throw new Error('polyfill failed because global object is unavailable in this environment');
}
}
let P = local.Promise;
if (P) {
var promiseToString = null;
try {
promiseToString = Object.prototype.toString.call(P.resolve());
} catch(e) {
// silently ignored
}
if (promiseToString === '[object Promise]' && !P.cast){
return;
}
}
local.Promise = Promise;
}