mirror of
https://github.com/imputnet/cobalt.git
synced 2024-12-28 02:26:10 +00:00
web/polyfills: add polyfill for AbortSignal.timeout
This commit is contained in:
parent
819c7a4fa0
commit
5ba83f3d56
|
@ -1 +1,2 @@
|
|||
import "./polyfills/user-activation";
|
||||
import "./polyfills/abortsignal-timeout";
|
||||
|
|
10
web/src/lib/polyfills/abortsignal-timeout.ts
Normal file
10
web/src/lib/polyfills/abortsignal-timeout.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { browser } from "$app/environment";
|
||||
|
||||
if (browser && 'AbortSignal' in window && !window.AbortSignal.timeout) {
|
||||
window.AbortSignal.timeout = (milliseconds: number) => {
|
||||
const controller = new AbortController();
|
||||
setTimeout(() => controller.abort("timed out"), milliseconds);
|
||||
|
||||
return controller.signal;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue