No Description

polyfill.js 594B

1234567891011121314151617181920212223242526
  1. /*global self*/
  2. import Promise from './promise';
  3. export default function polyfill() {
  4. var local;
  5. if (typeof global !== 'undefined') {
  6. local = global;
  7. } else if (typeof self !== 'undefined') {
  8. local = self;
  9. } else {
  10. try {
  11. local = Function('return this')();
  12. } catch (e) {
  13. throw new Error('polyfill failed because global object is unavailable in this environment');
  14. }
  15. }
  16. var P = local.Promise;
  17. if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) {
  18. return;
  19. }
  20. local.Promise = Promise;
  21. }