()
| 1120 | }; |
| 1121 | |
| 1122 | function polyfill() { |
| 1123 | var local = undefined; |
| 1124 | |
| 1125 | if (typeof global !== 'undefined') { |
| 1126 | local = global; |
| 1127 | } else if (typeof self !== 'undefined') { |
| 1128 | local = self; |
| 1129 | } else { |
| 1130 | try { |
| 1131 | local = Function('return this')(); |
| 1132 | } catch (e) { |
| 1133 | throw new Error('polyfill failed because global object is unavailable in this environment'); |
| 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | var P = local.Promise; |
| 1138 | |
| 1139 | if (P) { |
| 1140 | var promiseToString = null; |
| 1141 | try { |
| 1142 | promiseToString = Object.prototype.toString.call(P.resolve()); |
| 1143 | } catch (e) { |
| 1144 | // silently ignored |
| 1145 | } |
| 1146 | |
| 1147 | if (promiseToString === '[object Promise]' && !P.cast) { |
| 1148 | return; |
| 1149 | } |
| 1150 | } |
| 1151 | |
| 1152 | local.Promise = Promise; |
| 1153 | } |
| 1154 | |
| 1155 | // Strange compat.. |
| 1156 | Promise.polyfill = polyfill; |
nothing calls this directly
no outgoing calls
no test coverage detected