js/lcn/utils.js: move AbortSignal.any polyfill

This commit is contained in:
Jon 2024-02-20 23:23:44 +00:00 committed by towards-a-new-leftypol
parent 11011a0ff2
commit d2d5e98589
1 changed files with 16 additions and 0 deletions

View File

@ -31,3 +31,19 @@ const assert = {
} }
} }
} }
AbortSignal.any ??= function (signals) {
const controller = new AbortController()
const abortFn = () => {
for (const signal of signals) {
signal.removeEventListener("abort", abortFn)
}
controller.abort()
}
for (const signal of signals) {
signal.addEventListener("abort", abortFn)
}
return controller.signal
}