mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Chore: housekeeping
This commit is contained in:
@@ -8,11 +8,11 @@ class CustomAbortError extends Error {
|
||||
|
||||
const sleepWithAbort = (ms: number, signal: AbortSignal) => new Promise<void>((resolve, reject) => {
|
||||
if (signal.aborted) {
|
||||
reject(signal.reason);
|
||||
reject(signal.reason as Error);
|
||||
return;
|
||||
}
|
||||
|
||||
function stop(this: AbortSignal) { reject(this.reason); }
|
||||
function stop(this: AbortSignal) { reject(this.reason as Error); }
|
||||
|
||||
signal.addEventListener('abort', stop, { once: true });
|
||||
Bun.sleep(ms).then(resolve).catch(reject).finally(() => signal.removeEventListener('abort', stop));
|
||||
|
||||
Reference in New Issue
Block a user