kopia lustrzana https://github.com/cheeaun/phanpy
rodzic
940a94cd4a
commit
af99ae5100
|
@ -11,6 +11,36 @@ if ('AbortSignal' in window) {
|
|||
});
|
||||
}
|
||||
|
||||
// AbortSignal.any polyfill
|
||||
// Based on https://github.com/mozilla/pdf.js/pull/19681/files
|
||||
if ('AbortSignal' in window && !AbortSignal.any) {
|
||||
AbortSignal.any = function (iterable) {
|
||||
const ac = new AbortController();
|
||||
const { signal } = ac;
|
||||
|
||||
// Return immediately if any of the signals are already aborted.
|
||||
for (const s of iterable) {
|
||||
if (s.aborted) {
|
||||
ac.abort(s.reason);
|
||||
return signal;
|
||||
}
|
||||
}
|
||||
|
||||
// Register "abort" listeners for all signals.
|
||||
for (const s of iterable) {
|
||||
s.addEventListener(
|
||||
'abort',
|
||||
() => {
|
||||
ac.abort(s.reason);
|
||||
},
|
||||
{ signal }, // Automatically remove the listener.
|
||||
);
|
||||
}
|
||||
|
||||
return signal;
|
||||
};
|
||||
}
|
||||
|
||||
// URL.parse() polyfill
|
||||
if ('URL' in window && typeof URL.parse !== 'function') {
|
||||
URL.parse = function (url, base) {
|
||||
|
|
Ładowanie…
Reference in New Issue